[Solved] Simple initializer problem
-
Hi,
I am developing a Qt program with three libraries, but when compile the project, compiler return a error:
In file included from ../../../Sipred/src/app/core.h:32:0,
_ from ../../../Sipred/src/app/main.cpp:29:_
../../../Sipred/src/managers/interface/interfacemngr.h:38:42: error: expected initializer before ':' token
make[ 2 ]: *** [../../.obj/release/main.o] Error 1But I can't see anything wrong with that. If someone can take a look in my source code and give me advice about this problem I'll acknowledge.
Source code can be found at: "link":https://github.com/thanatosJSSE/Sipred/blob/master/src/managers/interface/interfacemngr.h
BR,
-
I'm not sure if this is the problem, but:
You declared InterfaceMngr as follows:[code]
class INTERFACEMNGR_EXPORT InterfaceMngr : public QObject
[/code]...but the symbol INTERFACEMNGR_EXPORT isn't always defined:
[code]
#if defined(INTERFACEMNGRLIB_LIBRARY)define INTERFACEMNGR_EXPORT Q_DECL_EXPORT
#else
define INTERFACEMNGR_IMPORT Q_DECL_IMPORT
#endif
[/code] -
Hi Mr. Universe,
Thank you for answer, but I define the simbol using my *.pro file:
@# interface_mngr.pro
DEFINES +=
INTERFACEMNGRLIB_LIBRARY@I thought that at the beginning, but ....
Best regards,
-
Additionally you could run qmake again.
If you want to be clear which code is used by the preprocessor you want to use a statement like this:
@#error "Simple"@
But I don't understand why you define the EXPORT and the IMPORT macro when using only the EXPORT in your class definition.
-
Hi franku,
You are right, but DEFINES qmake adds the values of this variable as compiler C preprocessor macros (-D option). So, when I add the line:
@# interface_mngr.pro
DEFINES +=
INTERFACEMNGRLIB_LIBRARY@it add
@#define INTERFACEMNGRLIB_LIBRARY@
Thank you for your time.
PD: When create shared lib follow this "link":http://doc.qt.nokia.com/4.7-snapshot/sharedlibrary.html#header-file-considerations
-
Hi, I know. This is the reason why I asked you to rebuild your makefiles using qmake. Just to be shure having the -D commandline parameter being passed to the compiler. Read the contents of the link again carefully to see where the difference is to your code.
You can use the #error to stop the preprocessor if you want to know which line is really evaluated.
-
I have found a strange issue:
I delete all references to InterfaceMngr in the file core.h and core.cpp, and found that the library compile without errors, but when I try to use it, give the compile error referenced here before.
BR,
-
Shouldn't it be:
@
#if defined(INTERFACEMNGRLIB_LIBRARY)define INTERFACEMNGR_EXPORT Q_DECL_EXPORT
#else
define INTERFACEMNGR_EXPORT Q_DECL_IMPORT
#endif
@otherwise, INTERFACEMNGR_EXPORT will not be defined when you try to use the exported symbol.
-
Hi Arnold,
I have other two similars definitions but don't have any problem.
The libraries "ModuleMngr":https://github.com/thanatosJSSE/Sipred/blob/master/src/managers/module/modulemngr.h and "PluginMngr":https://github.com/thanatosJSSE/Sipred/blob/master/src/managers/plugin/pluginmngr.h.Thank you.
-
In both pluginmngr_global.h and modulmngr_global.h the declaration looks like this
@
#ifndef PLUGINMNGR_GLOBAL_H
#define PLUGINMNGR_GLOBAL_H#include <QtCore/QtGlobal>
#if defined(PLUGINMNGRLIB_LIBRARY)
define PLUGINMNGR_EXPORT Q_DECL_EXPORT
#else
define PLUGINMNGR_EXPORT Q_DECL_IMPORT
#endif
#endif // PLUGINMNGR_GLOBAL_H
@which is exactly what i suggested.
Regards,
Arnold -
If i am not wrong there is a missing ";" after Q_DECLARE_PRIVATE(InterfaceMngr):
@
private:
Q_DECLARE_PRIVATE(InterfaceMngr) ; //here};
@ -
That's right, interfacemngr have his own interfacemngr_global.h.
And this looks like you suggest.
BR,
-
[quote author="Neutron Stein" date="1343136256"]If i am not wrong there is a missing ";" after Q_DECLARE_PRIVATE(InterfaceMngr):
@
private:
Q_DECLARE_PRIVATE(InterfaceMngr) ; //here};
@[/quote]There is no problem, I tried that too, without results.
I found that this library is compiled, but when I try to use it give me that error. -
Ok,
Thank everyone that helped me to take a look to mi code.
Well the problem was a personal mistake:@#if defined(INTERFACEMNGRLIB_LIBRARY)
define INTERFACEMNGR_EXPORT Q_DECL_EXPORT
#else
define INTERFACEMNGR_IMPORT Q_DECL_IMPORT <---- ERROR!!!
#endif@
Must be EXPORT like Arnold said
BR,