/Z7、/Zi、/ZI(调试信息格式)/Z7, /Zi, /ZI (Debug Information Format)

指定为您的程序并已将此信息保存在对象文件或程序数据库 (PDB) 文件中创建的调试信息的类型。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}/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. 此符号化调试信息可以包含由编译器生成的对象文件 (.obj 文件) 或可执行文件的独立 PDB 文件 (.pdb 文件) 中。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/Z7

/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. 会不生成任何 PDB 文件。No PDB file is produced.

对于第三方库的调试版本的分发服务器,没有到没有 PDB 文件的一个优点。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. 如果仅键入.pch 对象文件中的信息 (和无代码),还必须使用/Yl (为调试库插入 PCH 引用)选项,在生成库时,默认情况下,启用该选项。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.

/Gm (启用最小重新生成)选项不可用 /z7指定。The /Gm (Enable Minimal Rebuild) option is not available when /Z7 is specified.

/ZI/Zi

/Zi选项将生成单独的 PDB 文件包含所有的符号调试信息使用调试程序。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.

利用 /Zi不会影响优化。Use of /Zi does not affect optimizations. 但是, /Zi意味着 /debug; 请参阅/DEBUG (生成调试信息)有关详细信息。However, /Zi does imply /debug; see /DEBUG (Generate Debug Info) for more information.

同时指定当 /Zi/clr,则DebuggableAttribute属性不会放入程序集元数据。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. 详细了解如何Debuggable属性会影响性能以及如何可以修改性能的影响,请参阅令映像更易于调试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.

编译器命名的 PDB 文件项目.pdb。The compiler names the PDB file project.pdb. 如果编译在项目外部文件,编译器将创建一个名为 VC 的 PDB 文件x.pdb,其中x是串联中使用的编译器版本的主版本号和次版本号。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. 编译器将使用此选项,调试器指向符号和行号信息的位置创建的每个对象文件中嵌入 PDB 和标识的时间戳签名的名称。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. 名称和 PDB 文件中的签名必须匹配要在调试器中加载符号的可执行文件。The name and signature in the PDB file must match the executable for symbols to be loaded in the debugger. WinDBG 调试器可通过使用负载不匹配的符号.symopt+0x40命令。The WinDBG debugger can load mismatched symbols by using the .symopt+0x40 command. Visual Studio 没有加载不匹配的符号有类似选项。Visual Studio does not have a similar option to load mismatched symbols.

如果从使用已编译的对象创建一个库 /Zi,库链接到程序关联的.pdb 文件必须可用。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. 因此,如果分发此库,则还必须分发 PDB 文件。Thus, if you distribute the library, you must also distribute the PDB file. 若要创建的库,而无需使用 PDB 文件包含调试信息,必须选择 /z7选项。To create a library that contains debugging information without using PDB files, you must select the /Z7 option. 如果你使用预编译标头选项,预编译标头和源代码的其余部分调试信息放置在 PDB 文件中。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/ZI

/ZI选项是类似于 /Zi,它将生成的 PDB 文件中支持的格式,但编辑并继续功能。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. 由于大多数优化与编辑并继续不兼容,使用 /ZI禁用任何#pragma optimize在代码中的语句。Because most optimizations are incompatible with Edit and Continue, using /ZI disables any #pragma optimize statements in your code. /ZI选项也是与使用的不兼容 __行__预定义的宏; 使用代码编译 /ZI ,不能使用 __行__ 作为非类型模板参数,尽管 __行__ 可在宏扩展。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.

/ZI选项将强制同时/Gy (启用函数级链接)/FC (完整的源代码文件路径中诊断)在编译中使用的选项。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与不兼容/clr (公共语言运行时编译)/ZI is not compatible with /clr (Common Language Runtime Compilation).

备注

/ZI选项才可用面向 x86 和 x64 处理器的编译器中; 此编译器选项不是面向 ARM 处理器的编译器中可用。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.

在 Visual Studio 开发环境中设置此编译器选项To set this compiler option in the Visual Studio development environment

  1. 打开项目的“属性页” 对话框。Open the project's Property Pages dialog box. 有关详细信息,请参阅使用项目属性For details, see Working with Project Properties.

  2. 打开配置属性 > C/c + + > 常规属性页。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

编译器选项Compiler Options
设置编译器选项Setting Compiler Options