/Z7, /Zi, /ZI (Debug Information Format)

Specifies the type of debugging information created for your program and whether this information is kept in object files or in a program database (PDB) file.

Syntax

/Z{7|i|I}

Remarks

When code is compiled and built in debug mode, the compiler produces symbol names for functions and variables, type information, and line number locations for use by the debugger. This symbolic debugging information can be included either in the object files (.obj files) produced by the compiler, or in a separate PDB file (a .pdb file) for the executable. The debug information format options are described in the following sections.

None

By default, if no debug information format option is specified, the compiler produces no debugging information, so compilation is faster.

/Z7

The /Z7 option produces object files that also contain full symbolic debugging information for use with the debugger. These object files and the built executable can be substantially larger than files that have no debugging information. The symbolic debugging information includes the names and types of variables, as well as functions and line numbers. No PDB file is produced.

For distributors of debug versions of third-party libraries, there is an advantage to not having a PDB file. However, the object files for any precompiled headers are necessary during the library link phase, and for debugging. If there is only type information (and no code) in the .pch object file, you must also use the /Yl (Inject PCH Reference for Debug Library) option, which is enabled by default, when you build the library.

The deprecated /Gm (Enable Minimal Rebuild) option is not available when /Z7 is specified.

/Zi

The /Zi option produces a separate PDB file that contains all the symbolic debugging information for use with the debugger. The debugging information is not included in the object files or executable, which makes them much smaller.

Use of /Zi does not affect optimizations. However, /Zi does imply /debug; see /DEBUG (Generate Debug Info) for more information.

When you specify both /Zi and /clr, the DebuggableAttribute attribute is not placed in the assembly metadata. If you want it, you must specify it in the source code. This attribute can affect the runtime performance of the application. For more information about how the Debuggable attribute affects performance and how you can modify the performance impact, see Making an Image Easier to Debug.

The compiler names the PDB file project.pdb. If you compile a file outside of a project, the compiler creates a PDB file named VCx.pdb, where x is a concatenation of the major and minor version number of the compiler version in use. The compiler embeds the name of the PDB and an identifying timestamped signature in each object file created using this option, which points the debugger to the location of symbolic and line-number information. The name and signature in the PDB file must match the executable for symbols to be loaded in the debugger. The WinDBG debugger can load mismatched symbols by using the .symopt+0x40 command. Visual Studio does not have a similar option to load mismatched symbols.

If you create a library from objects that were compiled using /Zi, the associated .pdb file must be available when the library is linked to a program. Thus, if you distribute the library, you must also distribute the PDB file. To create a library that contains debugging information without using PDB files, you must select the /Z7 option. If you use the precompiled headers options, debugging information for both the precompiled header and the rest of the source code is placed in the PDB file.

/ZI

The /ZI option is similar to /Zi, but it produces a PDB file in a format that supports the Edit and Continue feature. To use Edit and Continue debugging features, you must use this option. The Edit and Continue feature is useful for developer productivity, but can cause issues in code size, performance, and compiler conformance. Because most optimizations are incompatible with Edit and Continue, using /ZI disables any #pragma optimize statements in your code. The /ZI option is also incompatible with use of the __LINE__ predefined macro; code compiled with /ZI cannot use __LINE__ as a non-type template argument, although __LINE__ can be used in macro expansions.

The /ZI option forces both the /Gy (Enable Function-Level Linking) and /FC (Full Path of Source Code File in Diagnostics) options to be used in your compilation.

/ZI is not compatible with /clr (Common Language Runtime Compilation).

Note

The /ZI option is only available in the compilers targeting x86 and x64 processors; this compiler option is not available in the compilers targeting ARM processors.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

  2. Open the Configuration Properties > C/C++ > General property page.

  3. Modify the Debug Information Format property. Choose OK to save your changes.

To set this compiler option programmatically

See also

MSVC Compiler Options
MSVC Compiler Command-Line Syntax