Qt preprocessor

What is the compilation order in QT? as I understand it, it is impossible to write

 
#define BEGIN_SIGNALS signals:

is the only way to do conditional compilation with only


#ifdef QT
signals:
#endif
+3
source share
3 answers

Just test it and

#define BEGIN_SIGNALS signals:

really works as expected since moc also does preprocessing.
The compilation order for the class QObject MyQObjectis -

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 compiled using your own compiler before or after.

Remember that the word itself signalsis a macro that converts to protectedwhen its own compiler is used. so I'm not sure why you ever want to define something like thisBEGIN_SIGNALS

+3
source
  • ?
  • ++, .
  • Qt, ? , , , ( ), Qt. (automake, cmake, ).
0

.

If QT then does not define “signals” as “protected”, this is what Qt does anyway so that the compiler does not shut down. You also need to define Q_OBJECT, emit (), and connect () to do nothing.

ps. You sometimes need to do this, I have a low-level library that is not dependent on Qt, but can send a Qt signal when an event occurs. Without Qt, it can send a Windows event or callback function.

0
source

Source: https://habr.com/ru/post/1794118/


All Articles