Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

PCH file?



  • i was under the impression that adding a PCH file effectively #includes that file in every single source file in my project. is this not true? must i also type #include <my_pch.h> into every source file? or: how do i get that file to be effectively included in every source?



  • windows (msvc):

    QMAKE_CXXFLAGS +=     /FI"stdafx.h"
    


  • @davecotter
    .pch just means pre-compiled header. It's for speed. It doesn't "actively put" anything into your file.

    You still have to choose what you #include in your source files. You can achieve getting multiple files included in source files in "one line" by having one .h header file have #include other files in it.



  • thanks for that. does anyone know a way to specify that a certain header file be automatically included in every file that is compiled, without having to type it in at the top of every .cpp file?



  • windows (msvc):

    QMAKE_CXXFLAGS +=     /FI"stdafx.h"
    

Log in to reply