Szerkesztés

Megosztás a következőn keresztül:


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

The /Z7, /Zi, and /ZI compiler options specify 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

/Z7
/Zi
/ZI

Remarks

When you specify a debug option, the compiler produces symbol names for functions and variables, type information, and line 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 any libraries built from them can be substantially larger than files that have no debugging information. The symbolic debugging information includes the names and types of variables, functions, and line numbers. No PDB file is produced by the compiler. However, a PDB file can still be generated from these object files or libraries if the linker is passed the /DEBUG option.

For distributors of debug versions of third-party libraries, there's 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's 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 unavailable 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 isn't included in the object files or executable, which makes them much smaller.

Use of /Zi doesn't affect optimizations. However, /Zi does imply /debug. For more information, see /DEBUG (Generate Debug Info).

When you specify both /Zi and /clr, the DebuggableAttribute attribute isn't 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, where <project> is the name of your project. If you compile a file outside of a project, the compiler creates a PDB file named VC<x>.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. This name and signature point 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 doesn't 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. That means, 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 can't 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 incompatible 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. Select 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