Reputation: 1965
What is the order of compiling in QT? as I understood it is impossible to write
#define BEGIN_SIGNALS signals:
is the only way to make conditional compilation only using
#ifdef QT
signals:
#endif
Upvotes: 4
Views: 1893
Reputation: 96109
You can do it the other way around.
If not QT then define 'signals' as 'protected' - which is what Qt does anyway so that compiler doesn't trip up. You also need to define Q_OBJECT, emit() and connect() to do nothing.
ps. You do sometimes need to do this, I have a low level lib that carefully doesn't depend on Qt - but it can send a Qt signal when an event occurs. Without Qt it can send a windows event or a callback function.
Upvotes: 0
Reputation: 7302
Upvotes: 0
Reputation: 78934
Just tested it and
#define BEGIN_SIGNALS signals:
does actually work as expected since moc does the preprocessing as well.
The order of compilation for a QObject
class MyQObject
is -
start moc for MyQObject.h
moc run the C preprocessor
moc produces the moc_MyObject.cpp file
moc_MyObject.cpp is compiled by the native compiler
MyQObject.cpp
is compiled by the native compiler before or after this.
Be mindful that the word signals
itself is a macro that translates to protected
when the native compiler is used. so I'm not sure why you would ever want to define something like this BEGIN_SIGNALS
Upvotes: 2