[Development] Question about QtSerialPort addons macro like QT_BEGIN(END...)_NAMESPACE_XYZ...
Denis Shienkov
scapig2 at yandex.ru
Fri Feb 17 14:10:37 CET 2012
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
More information about the Development
mailing list