I use gcc (running as g++
) and GNU make.
I use gcc to precompile a header file precompiled.h
, creating precompiled.h.gch
; the following line in a Makefile does it:
# MYCCFLAGS is a list of command-line parameters, e.g. -g -O2 -DNDEBUG
precompiled.h.gch: precompiled.h
g++ $(MYCCFLAGS) -c $< -o $@
All was well until i had to run g++
with different command-line parameters.
In this case, even though precompiled.h.gch
exists, it cannot be used, and the compilation will be much slower.
In the gcc documentation i have read that to handle this situation,
i have to make a directory called precompiled.h.gch
and put
the precompiled header files there,
one file for each set of g++
command-line parameters.
So now i wonder how i should change my Makefile to tell g++
to create
the gch-files this way.
Maybe i can run g++
just to test whether it can use any existing file
in the precompiled.h.gch
directory,
and if not, generate a new precompiled header with a unique file name.
Does gcc have support for doing such a test?
Maybe i can implement what i want in another way?