Share via


The /Fp (Specify Precompiled Header Filename) Option

The /Fp option gives you extra control over the name of the precompiled header (.PCH) file. Use it to specify a precompiled header filename that is different from the default. For example, use the following command to rename the default MSVC.PCH file created and used by the Automate Precompiled Header option:

CL /YX /FpMYPCH.PCH PROG.CPP

This command causes the compiler either to use a precompiled header named MYPCH.PCH if it exists or to create the file if it does not exist.

If you want to create a precompiled header file for a debugging version of your program and you are compiling both header files and source code, you can specify a command such as:

CL /DDEBUG /Zi /Yc /FpDPROG.PCH PROG.CPP

This command assumes the existence of a hdrstop pragma in PROG.CPP and creates a precompilation of all code up to the hdrstop pragma. The precompiled code is stored in a file called DPROG.PCH. If you need a release version in parallel, you simply change the compilation command to:

CL /Yc /FpRPROG.PCH PROG.CPP

This command creates a separate precompilation of all code up to the hdrstop pragma and stores it in RPROG.PCH.

You can also use the /Fp option with the /Yu and /YX options.