Anyone had any success getting precompiled headers working with GCC? I have had no luck in my attempts and I haven\'t seen many good examples for how to set it up. I\'ve t
The -x
specifier for C++ precompiled headers is -x c++-header
, not -x c++
. Example usage of PCH follows.
pch.h
:
// Put your common include files here: Boost, STL as well as your project's headers.
main.cpp
:
#include "pch.h"
// Use the PCH here.
Generate the PCH like this:
$ g++ -x c++-header -o pch.h.gch -c pch.h
The pch.h.gch
must be in the same directory as the pch.h
in order to be used, so make sure that you execute the above command from the directory where pch.h
is.