I don't think such a list exists. Some of the defines are for internal use only, some are explained either in the sources or in the docs. You could ask Trolltech for this, but I would expect an answer simmilar to "they are not to be used".
I don't think such a list exists. Some of the defines are for internal use only, some are explained either in the sources or in the docs. You could ask Trolltech for this, but I would expect an answer simmilar to "they are not to be used".
Q_OBJECT is used, right? Aren't there others?
"The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry
Obviously I'm only interested in the correct defines required to build a program that uses Qt, not the internal ones.Originally Posted by wysota
I will ask Trolltech and post the results here.
Save yourself some pain. Learn C++ before learning Qt.
Yop,
You don't have to care about these defines. They are automatically set by qmake. Just configure your .pro and let qmake does its job.
For instance, you talked about QtNetwork module. Just add this line in your .pro file and qmake will add the QT_NETWORK_LIB building flag.
[HTML]QT += network[/HTML]
If you want to know which option to append to QT .pro file variable, just open the QtAssistant and type the module name in the "Look for" entry of the index tab (eg: QtNetwork for the above example).
Who?Originally Posted by ldindon
Read my post again. I was talking about specifically when not using qmake. We use a totally different build system where I work.Originally Posted by ldindon
Save yourself some pain. Learn C++ before learning Qt.
Here's the reply I got from Trolltech:
...which is kind of unsubstantial. I can probably get close enough by observing the output from qmake-generated Makefiles, which is basically:Some of them I guess can be found here.
http://doc.trolltech.com/4.1/qtglobal.html
Others are scattered around the qmake docs. E.g. here:
http://doc.trolltech.com/4.1/qmake-advanced-usage.html
There are still quite a few that are undocumented I am afraid.
QT_DLL/QT_NODLL - define one or the other depending on whether using shared or static Qt libraries.
QT_NO_DEBUG/QT_DEBUG - define one or the other depending on whether using release or debug Qt
QT_PLUGIN - define when building a plugin library.
Define these accoring to which Qt libs you are linking with:
QT_CORE_LIB
QT_GUI_LIB
QT_XML_LIB
QT_NETWORK_LIB
QT_QT3SUPPORT_LIB
QT_OPENGL_LIB
QT_SQL_LIB
QT_SVG_LIB
These two only seem to be defined on Windows. (I was under the impression that multi-threading and 64-bit file offsets were the default in Qt4 anyway...).
QT_LARGEFILE_SUPPORT
QT_THREAD_SUPPORT
QT_SHARED - not sure what this is for?
Save yourself some pain. Learn C++ before learning Qt.
It probably means you're linking with shared Qt library. But IMHO this should only influence building Qt itself, not projects using it.Originally Posted by Chicken Blood Machine
Yeah, I would tend to agree, since QT_DLL, implies that you are linking with the shared Qt library, I would have guessed that QT_SHARED was an internal flag used when building Qt. Nevertheless, my small test program (on Suse Linux) shows a compile line containing -DQT_SHARED, when building a Makefile that was generated by qmake. Curious...Originally Posted by wysota
Save yourself some pain. Learn C++ before learning Qt.
QT_NO_DEBUG is defined in the Debugging Techniques paragraph of the manual. QT_DEBUG looks like an internal Qt macro that shouldn't be used by programmers.QT_NO_DEBUG/QT_DEBUG - define one or the other depending on whether using release or debug Qt
This looks like an internal Qt macro that shouldn't be used by programmers.QT_PLUGIN - define when building a plugin library.
I don't think any of these need to be defined, do they? They look like internal macros to me.Define these accoring to which Qt libs you are linking with:
QT_CORE_LIB
QT_GUI_LIB
QT_XML_LIB
QT_NETWORK_LIB
QT_QT3SUPPORT_LIB
QT_OPENGL_LIB
QT_SQL_LIB
QT_SVG_LIB
These are indeed for Qt 3 only, they have no effect whatsoever in Qt 4.These two only seem to be defined on Windows. (I was under the impression that multi-threading and 64-bit file offsets were the default in Qt4 anyway...).
QT_LARGEFILE_SUPPORT
QT_THREAD_SUPPORT
QT_LARGEFILE_SUPPORT is an internal macro that shouldn't be used by programmers. QT_THREAD_SUPPORT is defined in paragraph Thread Support in Qt of the Qt 3 manual.
OK, there's a lot of misunderstanding here. Here goes...
My questions are about what I need to have defined when building a project that uses the Qt libraries, but I using a build system other than qmake (i.e. what is automatically defined when using qmake). This is easy to see when looking at the compile commands invoked when calling 'make' on a makefile generated by qmake.Originally Posted by dimitri
QT_DEBUG is one of of such macros that need to be defined. Look at the output of any build when using CONFIG += debug.
See above. It does need to be defined when compiling a plugin.QT_PLUGIN - define when building a plugin library
This looks like an internal Qt macro that shouldn't be used by programmers.
Again - see above. qmake defines them all. Looking through the code, some of them don't seem to do anything (yet) but they may do in the future.Define these accoring to which Qt libs you are linking with:
QT_CORE_LIB
QT_GUI_LIB
QT_XML_LIB
QT_NETWORK_LIB
QT_QT3SUPPORT_LIB
QT_OPENGL_LIB
QT_SQL_LIB
QT_SVG_LIB
I don't think any of these need to be defined, do they? They look like internal macros to me.
You're probably right about these, but qmake still seems to define them on Windows. I am using Qt 4.1.0, YMMV.These two only seem to be defined on Windows. (I was under the impression that multi-threading and 64-bit file offsets were the default in Qt4 anyway...).
QT_LARGEFILE_SUPPORT
QT_THREAD_SUPPORT
These are indeed for Qt 3 only, they have no effect whatsoever in Qt 4.
So to sum up - Nearly all need to be defined under some circumstance or another. I just wanted to know the full list of macros and what those cicumstances were. Nevertheless I've worked most of it out myself by looking at the source. Hopefully there will be no nasty suprises down the road . My build system seems to be functioning correctly anyway.
Save yourself some pain. Learn C++ before learning Qt.
I don't think all of these macros need to be defined when building your own programs. For example QT_DEBUG clearly shouldn't need to be defined - from qglobal.h:The fact that qmake defines them doesn't necessarily mean you need them, qmake may define them because they're needed for building Qt itself.Qt Code:
/* Debugging and error handling */ #if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG) # define QT_DEBUG #endifTo copy to clipboard, switch view to plain text mode
That said, it's not a good idea for qmake to define macros that are not needed. Also it would indeed be a good idea to list all needed macros in a paragraph of the documentation. These really should be reported as a bug to Trolltech...
Indeed.Originally Posted by dimitri
My sentiments entirely.That said, it's not a good idea for qmake to define macros that are not needed. Also it would indeed be a good idea to list all needed macros in a paragraph of the documentation. These really should be reported as a bug to Trolltech...
Save yourself some pain. Learn C++ before learning Qt.
Bookmarks