How to use precompiled headers (pch) for C++ with Qt
-
Tried to google a little, but information is not much consistent...
Need to build faster my custom headers and Qt core/gui/widgets headers too -
Tried to google a little, but information is not much consistent...
Need to build faster my custom headers and Qt core/gui/widgets headers tooqmake: Using Precompiled Headers
cmake: target_precompile_headers -
qmake: Using Precompiled Headers
cmake: target_precompile_headers@ChrisW67 thanks :)
do you have real code sample I could refer to?as I can see the process, I need to insert
/* Add C includes here */ #if defined __cplusplus /* Add C++ includes here */ # include <iostream> # include <QApplication> # include <QPushButton> # include <QLabel> #endif
before every qt header and add smth to qt pro file?
-
@ChrisW67 thanks :)
do you have real code sample I could refer to?as I can see the process, I need to insert
/* Add C includes here */ #if defined __cplusplus /* Add C++ includes here */ # include <iostream> # include <QApplication> # include <QPushButton> # include <QLabel> #endif
before every qt header and add smth to qt pro file?
@JacobNovitsky
Here my own example:.pro file
CONFIG += precompile_header PRECOMPILED_HEADER = $$PWD/Application/Headers.pch
Headers.pch
// Prefix header #ifdef __cplusplus #include "QtMacros.h" #include "QtAppDefs.h" #endif
And you don't need to insert anything in your .h .cpp files.
-
@JacobNovitsky
Here my own example:.pro file
CONFIG += precompile_header PRECOMPILED_HEADER = $$PWD/Application/Headers.pch
Headers.pch
// Prefix header #ifdef __cplusplus #include "QtMacros.h" #include "QtAppDefs.h" #endif
And you don't need to insert anything in your .h .cpp files.
@mpergand is it nessesary to change .h to .pch or I can use .h file too?
-
@mpergand is it nessesary to change .h to .pch or I can use .h file too?
@JacobNovitsky Call the file whatever you like.
-
-
@JacobNovitsky Call the file whatever you like.
@ChrisW67 how to test if its already pre-compiled, my complier does not compile this particular header?
https://forum.qt.io/topic/151001/additional-info-upon-compiling-with-qt-creator -
@ChrisW67 how to test if its already pre-compiled, my complier does not compile this particular header?
https://forum.qt.io/topic/151001/additional-info-upon-compiling-with-qt-creator@JacobNovitsky Please stop creating new threads for the same conversation.
-
-
C Christian Ehrlicher referenced this topic on
-
@JacobNovitsky Please stop creating new threads for the same conversation.
-
C Christian Ehrlicher locked this topic on