[zscript/ExportedNatives] GCC/Clang compiling errors

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [zscript/ExportedNatives] GCC/Clang compiling errors

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Tue Nov 15, 2016 4:11 am

The error was simply that the template referred to a variable that was declared after the template in the source file. Depending on when a template's references are resolved that will pass, if this takes place at instantiation or will fail if it takes place at compile time. Just moving the declarations up, before the template made the errors go away.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by ZzZombo » Tue Nov 15, 2016 3:52 am

Sorry if I was not clear, I asked what did Leonard do exactly to solve the problem. I get it's the templates that enabled him to do so, but not the underlying mechanism behind.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Tue Nov 15, 2016 2:41 am

Those templates are used as a 'glue' class between the scripted and the native class to add wrappers that can redirect the virtual functions to the VM.
Such a class needs to be added for each native class that is being used as a parent of scripted classes and exports virtual functions and the template will generate most of this automatically.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by ZzZombo » Mon Nov 14, 2016 7:21 pm

So, can somebody tell what exactly was done, for non experts in C++ templates?

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by kevans91 » Fri Nov 11, 2016 9:27 am

FWIW: Can confirm, also compiles fine w/ Clang defaults using Leonard2's latest version

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Fri Nov 11, 2016 9:22 am

So, it was all just a missing declaration, because it was too late in the source? Oh well, finally I can start with the virtual function implementation...

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Leonard2 » Fri Nov 11, 2016 9:16 am

The real problem here was the compilers not implementing it in the same way.
If MSVC had a correct implementation no one would have run into this issue.
Fixed the remaining errors.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Fri Nov 11, 2016 9:07 am

Well, if you ask me this two-phase lookup rule is utterly boneheaded. Whoever invented that should rot in hell.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by kevans91 » Fri Nov 11, 2016 8:54 am

Default options w/ Clang:
Spoiler:

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Fri Nov 11, 2016 8:45 am

Ok. Can you post another error list you get with the default setting?

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Edward-san » Fri Nov 11, 2016 8:13 am

I can provide more fixes for the errors which are not from the delayed template parsing, I'm preparing a pr.

[edit] Done.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by kevans91 » Fri Nov 11, 2016 8:06 am

Hi,

Still problems here (Clang) -- excerpt:
Spoiler:

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Fri Nov 11, 2016 7:51 am

Actually, it wouldn't surprise me if this:

Code: Select all

/home/edward-san/zdoom/branch/zscript/src/./dobject.h:179:134: error: pasting "::" and "Destroy" does not give a valid preprocessing token
  *ptr, args ... arglist) { return static_cast<object *>(ptr)->object::##func(arglist...); }


is the entire problem. Why does it even need the token paste operator (##)? It compiles fine without it and this is definitely not how it's supposed to be used.
Would be nice if someone could check the latest commit.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Leonard2 » Fri Nov 11, 2016 7:35 am

Well no luck for MingGW then.
If anyone who is able to compile with GCC/Clang on linux would accept to test a few quick patches from me (contact via Steam/IRC would be preferred) that would really be appreciated.
In the mean time I have no means to test for a potential fix.

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

by Graf Zahl » Fri Nov 11, 2016 6:31 am

MinGW does not work at the moment. Its Windows headers are far too broken. I eventually gave up fixing all the issues that got reported. If they insist on providing obsolete system headers the compiler is useless.

Top