E
E
evgeniyup2012-10-07 02:49:05
Programming
evgeniyup, 2012-10-07 02:49:05

Question for GCC and C++ template experts

Question for GCC and C++ template experts. I built a large module on templates, it compiles and works in the studio, but throws a bunch of errors on GCC. So many that it's even hard to understand what exactly GCC dislikes so much.

I'm trying to compile this file .

Can anyone help me resolve the issue or point me in the right direction?

Thank you.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
E
egorinsk, 2012-10-07
@egorinsk

I have a slightly offtopic question, why do you make files of 20,000 lines each? This is pure drug addiction. We would make a set of small files, it would be easier to look for an error in 200 lines than in 20,000.

E
EaS, 2012-10-07
@EaS

1) Usually they ask for help on the most reduced version of the code that gives an error.
2) Are you using C++11? If so, try adding -std=c++11 to the compilation.
3) You have a bunch of ifdefs. Give better preprocessor output. It is unlikely that someone will want to specifically download your project for you, look for a compilation command, etc. (point 1 still does not cancel)
4) Did you try to enter here ? Or here ?

V
vScherba, 2012-10-07
@vScherba

I did not climb into the code, but according to the description of the error, everything “explicit specialization in non-namespace scope” is clear. I've encountered before. Somewhere inside the structure OS_FunctionClassImpConst0__cdecl you have specialized a template. This is prohibited by the standard, you can specialize a template only inside the namespace, including the global one. But MSVC allows inside structures/classes.

E
evgeniyup, 2012-10-07
@evgeniyup

Of course, you can show the output:
c:/sources/cocos2d-os/modules/objectscript/source/objectscript.cpp(3) : from c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h(474): error : explicit specialization in non-namespace scope 'struct OS_FunctionClassImpConst0__cdecl<R, T>' c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h(475): error : template-id 'run<void>' in declaration of primary template c:/sources/cocos2d-os/modules/objectscript/source/os-binder-cc-functions.h(35) :In file included from c:/sources/cocos2d-os/modules/objectscript/source/os-binder-arg-cc-functions.h(35) : from c:/sources/cocos2d-os/modules/objectscript/source/os-binder.h(589) : from c:/sources/cocos2d-os/modules/objectscript/source/objectscript.cpp(3) : from c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h( In constructor 'OS_FunctionClassImpConst0__cdecl<R, T>) ::OS_FunctionClassImpConst0__cdecl(const char*, int)': c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h(460): error : class 'OS_FunctionClassImpConst0__cdecl<R, T>' does not have any field named 'f' c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h( In static member function 'static int OS_FunctionClassImpConst0__cdecl<R, T>) ::run(ObjectScript::OS*, int, int, int, void*)': c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h(465): error : 'OS_E_ERROR' was not declared in this scope c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h(465): error : 'OS' has not been declared c:/sources/cocos2d-os/modules/objectscript/source/os-binder-cc-functions.h(35) :In file included from c:/sources/cocos2d-os/modules/objectscript/source/os-binder-arg-cc-functions.h(35) : from c:/sources/cocos2d-os/modules/objectscript/source/os-binder.h(589) : from c:/sources/cocos2d-os/modules/objectscript/source/objectscript.cpp(3) : from c:/sources/cocos2d-os/modules/objectscript/source/os-binder-function.h(468): error : 'F' was not declared in this scope
etc.
Let me remind you that there is no problem under the studio.

I
Ivan Pavlenko, 2012-10-07
@MrGobus

Usually a mistake in any template causes a lot of compilation errors, since one instantly starts to lead to new new and new, rake from top to bottom and you will be pleasantly surprised how the number of errors will begin to decrease in the same progression as they were formed.
Further, bare g ++ is usually not configured for error exception handling and does by default, the same visual studio or code blocks substitute different error checking keys like -Wall, etc. when compiling. So g++

R
Roman, 2012-10-07
@WNeZRoS

I didn’t really look at the code, but I had a similar studio with a template (it compiles in the studio, not in gcc). The problem was solved by moving the body of the template methods/classes to the .h file.

E
evgeniyup, 2012-10-08
@evgeniyup

Thanks for your help, issue resolved. Basically there were two problems:
1. template <> static int run inside the template class
2. using __cdecl, __stdcall, etc. - this had to be removed altogether for GCC, __attribute__ ((cdecl)) and so on. did not help

M
Mercury13, 2014-03-14
@Mercury13

All I know is that GCC is the most "corrosive" compiler. After Intel and Embarcadero (I don’t know about M$), GCC will find another two dozen errors on the “patterned” code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question