I answer to myself. If add in serialport_global.h also these lines: .. #if defined QT_BEGIN_MOC_NAMESPACE # undef QT_BEGIN_MOC_NAMESPACE #endif #if defined QT_END_MOC_NAMESPACE # undef QT_END_MOC_NAMESPACE #endif
#define QT_BEGIN_MOC_NAMESPACE QT_BEGIN_NAMESPACE_SERIALPORT #define QT_END_MOC_NAMESPACE QT_END_NAMESPACE_SERIALPORT .. then the MOC without error and the project compiles successfully. But is it correct or not for Addons modules? Or is it better to replace macros QT_BEGIN (END) _NAMESPACE_XYZ to the Qt standard macros default QT_BEGIN (END) _NAMESPACE ?? Best regards, Denis 17.02.2012, 17:10, "Denis Shienkov" <[email protected]>: > Hi, all. > > I am developing a new addon for Qt5 in Gerrit /playground/QtSerialPort and I > have a > problem with the macros QT_BEGIN_NAMESPACE_SERIALPORT, > QT_END_NAMESPACE_SERIALPORT and etc. > > With this code in the global file serialport-global.h > ... > #ifndef SERIALPORT_GLOBAL_H > #define SERIALPORT_GLOBAL_H > > #include "qglobal.h" > > #if defined(QT_ADDON_SERIALPORT_LIB) > # define Q_ADDON_SERIALPORT_EXPORT Q_DECL_EXPORT > #else > # define Q_ADDON_SERIALPORT_EXPORT Q_DECL_IMPORT > #endif > > #if defined(QT_NAMESPACE) > # define QT_BEGIN_NAMESPACE_SERIALPORT namespace QT_NAMESPACE { namespace > QtAddOn { namespace SerialPort { > # define QT_END_NAMESPACE_SERIALPORT } } } > # define QT_USE_NAMESPACE_SERIALPORT using namespace > QT_NAMESPACE::QtAddOn::SerialPort; > # define QT_PREPEND_NAMESPACE_SERIALPORT(name) > ::QT_NAMESPACE::QtAddOn::SerialPort::name > #else > # define QT_BEGIN_NAMESPACE_SERIALPORT namespace QtAddOn { namespace > SerialPort { > # define QT_END_NAMESPACE_SERIALPORT } } > # define QT_USE_NAMESPACE_SERIALPORT using namespace QtAddOn::SerialPort; > # define QT_PREPEND_NAMESPACE_SERIALPORT(name) ::QtAddOn::SerialPort::name > #endif > */ > > // a workaround for moc - if there is a header file that doesn't use > processmanager > // namespace, we still force moc to do "using namespace" but the namespace > have to > // be defined, so let's define an empty namespace here > QT_BEGIN_NAMESPACE_SERIALPORT > QT_END_NAMESPACE_SERIALPORT > > #endif // SERIALPORT_GLOBAL_H > ... > > Project addon does not compile, there are errors in the files moc_xxx.cpp who > say that in project - classes and enums, etc. not defined. > > Although, in all h/cpp files have macros like QT_BEGIN_NAMESPACE_SERIALPORT > and QT_END_NAMESPACE_SERIALPORT. > I designed the project, by analogy with the addons projects of the > playground, such as qtprojectmanager, qtjsonstream... > > If I define a macro as a stub (empty) - a project compiles without errors. > > Please help me. > > Best regards, > Denis _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
