Re: pre-compiled header file by Carl
Carl
Sun Jun 20 20:48:32 CDT 2004
pat wrote:
> To use pre-compiled header file, for the first time of compiling a
> project, we have to specify "Not use pre-compiled header file" in the
> project's Setting options, since there is no .pch file yet and for
> each project, the .PCH file could be different. Is this correct?
>
> In a Windows console program, is the "stdafx.h" header file that
> determines what to be included in the .PCH file?
>
> Is "stdafx.h" header file can be compiled, can other header files
> like being created by myself be compile as well?
If you create a C++ project using the standard "new project" wizards, the
project will be created with support for a PCH file (unless you checked the
"empty project" checkbox, that is).
To use a precompiled header file:
- You must have a single header that's #included before anything else in
every file that uses the pch file. This file is (badly) named 'stdafx.h' by
the new-project wizards. Personally, I think 'pch.h' is a much better name
:)
- You must compile one module of your project with /Yc ("Create Precompiled
Header File"). The new-project wizards always make a file named
'stdafx.cpp' that is built with /Yc, but it can be any one module in your
project.
- You must compile all of the other modules that are to use the PCH file
with /Yu ("Use Precompiled Header File").
You can set all of this up in the IDE if you started from a blank project.
See Project|Properties|Precompiled Header Files.
-cd