The /Yd (Duplicate Debugging Information in All Object Files) Option

Home

Use the /Yd (Duplicate Debugging Information in All Object Files) option with the /Z7 (Generate Microsoft C/C++ Version 7.0 Compatible CodeView Information) option to place complete debugging information in all object files that are ultimately created from the resulting precompiled header (.PCH) file. The /Yd option takes no argument.

Note   The /Yd option is obsolete with the advent of the new program database (PDB) files created by the “generate complete debugging information” (/Zi) option. The /Yd option is retained on /Zi, /Zd, and /Z7 for backward compatibility with Microsoft C/C++ version 7.0.

Storing complete debugging information in every object file, including the information that describes only the .PCH file, is sometimes convenient, but it slows compilation and requires considerable disk space.

In contrast, when /Yc and /Z7 are used without /Yd, the compiler stores debugging information describing the .PCH file in the first object file created from that file. The compiler does not insert this common debugging information into object files subsequently created from the .PCH file; rather, it inserts cross-references to the debugging information. Therefore, no matter how many object files use the .PCH file, only one object file contains the common debugging information.

Although this default behavior results in faster build times and reduces disk-space demands, it is undesirable if a small change requires rebuilding the object file containing the common debugging information. In this case, the compiler must rebuild all object files containing cross-references to the original object file. Also, it is difficult to rely on cross-references to a single object file if a common .PCH file is used by different projects.

Examples

Suppose you have two base files, F.CPP and G.CPP, each containing 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 /Z7 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 /Z7 G.CPP

The object file G.OBJ does not include the debugging information for the precompiled header but simply references that information in the F.OBJ file. Note that you must link with the F.OBJ.

If your precompiled header was not compiled with /Z7, you can still use it in later compilations using /Z7. However, the debugging information is placed in the current object file, and local symbols for functions and types defined in the precompiled header are not available to the debugger.