This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RedHat precompiled-header code branch created

Here's the README we originally sent to the customer; I think it still
describes the software from a user level.  For keeping the PCH files
up-to-date, the recommended software is make(1).

Using PCH

A header 'foo.h' can be precompiled as follows:

gcc -c foo.h

This creates a file 'foo.h.pch'.  This file represents the effect
of including foo.h as the first thing in a compilation.

You can use

gcc -c -x c-header foo.h

to override the usual GCC filetype-guessing mechanism based on suffixes;
you would want to do this if the header does not end in .h.

You should supply exactly the same options to this compilation as
you expect to use in the final build, except that you may omit
-D options for tokens that do not occur anywhere in foo.h.
This includes code generation and optimization options.

The compiler will search for 'foo.h.pch' when it sees

#include "foo.h"

or similar in a compilation.  It will use whichever of foo.h or
foo.h.pch it finds first along the usual search path.  The precompiled
header name is generated by appending `.pch' to the original header
name.  Generally, a precompiled header can only be used if the
#include is the first non-whitespace token in a compilation.

- Geoffrey Keating <>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]