Skip to content

Commit 20a34b4

Browse files
author
Colin Robertson
authored
Fix confusing /Z7 documentation per Paddy McDonald in 2289 (#2972)
* Update /Z7 per 2289 * Add project explanation * Format fix
1 parent 4c76e1d commit 20a34b4

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
---
22
title: "/Z7, /Zi, /ZI (Debug Information Format)"
3-
ms.date: "04/08/2019"
3+
ms.date: "07/06/2020"
44
f1_keywords: ["VC.Project.VCCLCompilerTool.DebugInformationFormat", "/ZI", "/Zi", "/Z7", "VC.Project.VCCLWCECompilerTool.DebugInformationFormat"]
55
helpviewer_keywords: ["C7 compatible compiler option [C++]", "Debug Information Format compiler option", "ZI compiler option", "-Zi compiler option [C++]", "/ZI compiler option [C++]", "Z7 compiler option [C++]", "debugging [C++], debug information files", "Zi compiler option [C++]", "/Zi compiler option [C++]", "program database compiler option [C++]", "full symbolic debugging information", "/Z7 compiler option [C++]", "line numbers only compiler option [C++]", "cl.exe compiler, debugging options", "-Z7 compiler option [C++]"]
66
---
77
# /Z7, /Zi, /ZI (Debug Information Format)
88

9-
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.
9+
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.
1010

1111
## Syntax
1212

13-
> **/Z**{**7**|**i**|**I**}
13+
> **`/Z7`**\
14+
> **`/Zi`**\
15+
> **`/ZI`**
1416
1517
## Remarks
1618

17-
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.
19+
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.
1820

1921
### None
2022

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

2325
### /Z7
2426

25-
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.
27+
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.
2628

27-
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)](yl-inject-pch-reference-for-debug-library.md) option, which is enabled by default, when you build the library.
29+
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)](yl-inject-pch-reference-for-debug-library.md) option, which is enabled by default, when you build the library.
2830

29-
The deprecated [/Gm (Enable Minimal Rebuild)](gm-enable-minimal-rebuild.md) option is not available when **/Z7** is specified.
31+
The deprecated [`/Gm` (Enable Minimal Rebuild)](gm-enable-minimal-rebuild.md) option is unavailable when **`/Z7`** is specified.
3032

3133
### /Zi
3234

33-
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.
35+
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.
3436

35-
Use of **/Zi** does not affect optimizations. However, **/Zi** does imply **/debug**; see [/DEBUG (Generate Debug Info)](debug-generate-debug-info.md) for more information.
37+
Use of **`/Zi`** doesn't affect optimizations. However, **`/Zi`** does imply **`/debug`**. For more information, see [`/DEBUG` (Generate Debug Info)](debug-generate-debug-info.md).
3638

37-
When you specify both **/Zi** and **/clr**, the <xref:System.Diagnostics.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](/dotnet/framework/debug-trace-profile/making-an-image-easier-to-debug).
39+
When you specify both **`/Zi`** and **`/clr`**, the <xref:System.Diagnostics.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](/dotnet/framework/debug-trace-profile/making-an-image-easier-to-debug).
3840

39-
The compiler names the PDB file *project*.pdb. 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, 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.
41+
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.
4042

41-
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.
43+
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.
4244

4345
### /ZI
4446

45-
The **/ZI** option is similar to **/Zi**, but it produces a PDB file in a format that supports the [Edit and Continue](/visualstudio/debugger/edit-and-continue-visual-cpp) 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 [&#95;&#95;LINE&#95;&#95; predefined macro](../../preprocessor/predefined-macros.md); code compiled with **/ZI** cannot use **&#95;&#95;LINE&#95;&#95;** as a non-type template argument, although **&#95;&#95;LINE&#95;&#95;** can be used in macro expansions.
47+
The **`/ZI`** option is similar to **`/Zi`**, but it produces a PDB file in a format that supports the [Edit and Continue](/visualstudio/debugger/edit-and-continue-visual-cpp) 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](../../preprocessor/predefined-macros.md); code compiled with **`/ZI`** can't use `__LINE__` as a non-type template argument, although `__LINE__` can be used in macro expansions.
4648

47-
The **/ZI** option forces both the [/Gy (Enable Function-Level Linking)](gy-enable-function-level-linking.md) and [/FC (Full Path of Source Code File in Diagnostics)](fc-full-path-of-source-code-file-in-diagnostics.md) options to be used in your compilation.
49+
The **`/ZI`** option forces both the [`/Gy` (Enable Function-Level Linking)](gy-enable-function-level-linking.md) and [`/FC` (Full Path of Source Code File in Diagnostics)](fc-full-path-of-source-code-file-in-diagnostics.md) options to be used in your compilation.
4850

49-
**/ZI** is not compatible with [/clr (Common Language Runtime Compilation)](clr-common-language-runtime-compilation.md).
51+
**`/ZI`** is incompatible with [`/clr` (Common Language Runtime Compilation)](clr-common-language-runtime-compilation.md).
5052

5153
> [!NOTE]
52-
> 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.
54+
> 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.
5355
5456
### To set this compiler option in the Visual Studio development environment
5557

@@ -65,5 +67,5 @@ The **/ZI** option forces both the [/Gy (Enable Function-Level Linking)](gy-enab
6567

6668
## See also
6769

68-
[MSVC Compiler Options](compiler-options.md)<br/>
69-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
70+
[MSVC compiler options](compiler-options.md)<br/>
71+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

0 commit comments

Comments
 (0)