Strange error when is include new class. (MSVS 2010)
-
When I add a header file of my class then is happen this error:
@1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ')' before 'constant'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ';' before 'constant'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2805: binary 'operator |' has too few parameters
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : ')'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ';' before '{'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2447: '{' : missing function header (old-style formal list?)
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ')' before 'constant'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ';' before 'constant'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : ')'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : '}'
1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : '}'@When I into my primary Main Window class add this
@#include "mynewclass.h"@If I comment this piece of code:
@//#include "mynewclass.h"@Everything works fine.
Class is usual C++ class (no QT) and in my test project works fine, so in class shouldn´t be error. I don´t understand this error and link between add new class and qeventloop…
-
-
Should I include header of my classes before include of QT header?
Anyway you answer helped me – thank you. The mistake was in defined of constants. In my class I have lots of constants (like this: #define xy 1234) and it´s caused the error. Now I´m (thank to you) a little bit smarter. How you wrote probably some constant was define twice…
-
If possible, you could change to true constants, instead of preprocessor macros.
If you need to stick to macros, it's always a good idea to start the macro names with some prefix common to you project, so for example instead of just using NUMFILES, it would be better to use QTC_NUMFILES (if we assume coding for Qt Creator here). This way you have much better chances that it doesn't clash with some other #defines.