The /Yd “debugging information” option allows you to override the default placement of CodeView information in object files. It is used with precompiled headers created with the /Zi option.
By default, any CodeView debugging information (symbols and type information) for a precompiled header is placed in the object file for which the precompiled header is created, rather than in the .PCH file itself. When you create other object files using this precompiled header, the new object files do not replicate the same debugging information. Instead, they simply cross-reference the debugging information contained in the first object file. By cross-referencing this information, rather than replicating it in multiple object files, you can save disk space and speed up the build process.
For example, say that you have two base files, F.CPP and G.CPP, each of which contains these #include statements:
#include "windows.h"
#include "etc.h"
. . . .
The following command creates the precompiled header file ETC.PCH and the object file F.OBJ:
CL /YcETC.H /Zi F.CPP
The object file F.OBJ includes type and symbol information for WINDOWS.H and ETC.H (and any other header files they include). Now you can use the precompiled header ETC.PCH to compile the source file G.CPP:
CL /YuETC.H /Zi G.CPP
The object file G.OBJ does not include the debugging information for the precompiled header, but simply cross-references that information in the F.OBJ file. Note that you must link with the F.OBJ file if you choose to link with the /CODEVIEW option.
If your precompiled header was not compiled with /Zi, you can still use it in later compilations using /Zi. However, the debugging information will be placed in the current object file, and local symbols for functions defined in the precompiled header will not be available to CodeView.
The default behavior described above can be undesirable if you are distributing a debugging library. The /Yd option lets you override the default, in order to place complete debugging information in every object file. The syntax for this option is:
/Yd
When you create a precompiled header using /Yd, the .PCH file itself contains the debugging information. When you use a precompiled header using /Yd, the debugging information is replicated in the resulting object file.