|
1 | 1 | ---
|
2 | 2 | title: "-Z7, -Zi, -ZI (Debug Information Format) | Microsoft Docs"
|
3 | 3 | ms.custom: ""
|
4 |
| -ms.date: "11/04/2016" |
5 |
| -ms.reviewer: "" |
6 |
| -ms.suite: "" |
| 4 | +ms.date: "02/22/2018" |
7 | 5 | ms.technology: ["cpp-tools"]
|
8 |
| -ms.tgt_pltfrm: "" |
9 |
| -ms.topic: "article" |
10 |
| -f1_keywords: ["VC.Project.VCCLCompilerTool.DebugInformationFormat", "/zi", "/z7", "VC.Project.VCCLWCECompilerTool.DebugInformationFormat"] |
| 6 | +ms.topic: "reference" |
| 7 | +f1_keywords: ["VC.Project.VCCLCompilerTool.DebugInformationFormat", "/ZI", "/Zi", "/Z7", "VC.Project.VCCLWCECompilerTool.DebugInformationFormat"] |
11 | 8 | dev_langs: ["C++"]
|
12 |
| -helpviewer_keywords: ["C7 compatible compiler option [C++]", "-Zl 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++]", "none 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++]"] |
13 |
| -ms.assetid: ce9fa7e1-0c9b-47e3-98ea-26d1a16257c8 |
14 |
| -caps.latest.revision: 21 |
| 9 | +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++]"] |
15 | 10 | author: "corob-msft"
|
16 | 11 | ms.author: "corob"
|
17 | 12 | manager: "ghogen"
|
18 | 13 | ms.workload: ["cplusplus"]
|
19 | 14 | ---
|
20 | 15 | # /Z7, /Zi, /ZI (Debug Information Format)
|
21 |
| -Select the type of debugging information created for your program and whether this information is kept in object (.obj) files or in a program database (PDB). |
22 |
| - |
23 |
| -## Syntax |
24 |
| - |
25 |
| -``` |
26 |
| -/Z{7|i|I} |
27 |
| -``` |
28 |
| - |
29 |
| -## Remarks |
30 |
| - The options are described in the following table. |
31 |
| - |
32 |
| - None |
33 |
| - Produces no debugging information, so compilation is faster. |
34 |
| - |
35 |
| - **/Z7** |
36 |
| - Produces an .obj file containing full symbolic debugging information for use with the debugger. The symbolic debugging information includes the names and types of variables, as well as functions and line numbers. No .pdb file is produced. |
37 |
| - |
38 |
| - For distributors of third-party libraries, there is an advantage to not having a .pdb file. However, the .obj files for the precompiled headers are necessary during the link phase, and debugging. If there is only type information (and no code) in the .pch object files, you will also have to compile with [/Yl (Inject PCH Reference for Debug Library)](../../build/reference/yl-inject-pch-reference-for-debug-library.md). |
39 |
| - |
40 |
| - **/Zi** |
41 |
| - Produces a program database (PDB) that contains type information and symbolic debugging information for use with the debugger. The symbolic debugging information includes the names and types of variables, as well as functions and line numbers. |
42 |
| - |
43 |
| - **/Zi** does not affect optimizations. However, **/Zi** does imply **/debug**; see [/DEBUG (Generate Debug Info)](../../build/reference/debug-generate-debug-info.md) for more information. |
44 |
| - |
45 |
| - Type information is placed in the .pdb file, and not in the .obj file. |
46 |
| - |
47 |
| - You can use [/Gm (Enable Minimal Rebuild)](../../build/reference/gm-enable-minimal-rebuild.md) with **/Zi**, whereas **/Gm** is not available when compiling with **/Z7**. |
48 |
| - |
49 |
| - When compiling with **/Zi** and **/clr**, the <xref:System.Diagnostics.DebuggableAttribute> attribute will not be placed in the assembly metadata; you must specify it in source code, if you want it. 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). |
50 |
| - |
51 |
| - **/ZI** |
52 |
| - Produces a program database, as described above, in a format that supports the Edit and Continue feature. If you want to use Edit and Continue debugging, you must use this option. Because most optimizations are incompatible with Edit and Continue, using **/ZI** disables any `#pragma optimize` statements in your code. |
53 |
| - |
54 |
| - **/ZI** causes [/Gy (Enable Function-Level Linking)](../../build/reference/gy-enable-function-level-linking.md) and [/FC (Full Path of Source Code File in Diagnostics)](../../build/reference/fc-full-path-of-source-code-file-in-diagnostics.md) to be used in your compilation. |
55 |
| - |
56 |
| - **/ZI** is not compatible with [/clr (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md). |
57 |
| - |
| 16 | + |
| 17 | +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. |
| 18 | + |
| 19 | +## Syntax |
| 20 | + |
| 21 | +> **/Z**{**7**|**i**|**I**} |
| 22 | +
|
| 23 | +## Remarks |
| 24 | + |
| 25 | +The debug information format options are described in the following sections. |
| 26 | + |
| 27 | +### None |
| 28 | + |
| 29 | +By default, if no debug information format option is specified, the compiler produces no debugging information, so compilation is faster. |
| 30 | + |
| 31 | +### /Z7 |
| 32 | + |
| 33 | +The **/Z7** option produces an *object file*, a file that has a .obj extension, containing full symbolic debugging information for use with the debugger. The symbolic debugging information includes the names and types of variables, as well as functions and line numbers. No *PDB file*, a file with a .pdb extension, is produced. |
| 34 | + |
| 35 | +For distributors of third-party libraries, there is an advantage to not having a PDB file. However, the object files for the precompiled headers are necessary during the link phase, and for debugging. If there is only type information (and no code) in the .pch object files, you must also use the [/Yl (Inject PCH Reference for Debug Library)](../../build/reference/yl-inject-pch-reference-for-debug-library.md) option, which is enabled by default. |
| 36 | + |
| 37 | +### /Zi |
| 38 | + |
| 39 | +The **/Zi** option produces a PDB file that contains type information and symbolic debugging information for use with the debugger. The symbolic debugging information includes the names and types of variables, as well as functions and line numbers. |
| 40 | + |
| 41 | +Use of **/Zi** does not affect optimizations. However, **/Zi** does imply **/debug**; see [/DEBUG (Generate Debug Info)](../../build/reference/debug-generate-debug-info.md) for more information. |
| 42 | + |
| 43 | +When **/Zi** is specified, type information is placed in the PDB file, and not in the object file. |
| 44 | + |
| 45 | +You can use [/Gm (Enable Minimal Rebuild)](../../build/reference/gm-enable-minimal-rebuild.md) together with **/Zi**, but **/Gm** is not available when **/Z7** is specified. |
| 46 | + |
| 47 | +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 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). |
| 48 | + |
| 49 | +### /ZI |
| 50 | + |
| 51 | +The **/ZI** option produces a PDB file in a format that supports the [Edit and Continue](/visualstudio/debugger/edit-and-continue-visual-cpp) feature. If you want to use Edit and Continue debugging, you must use this option. The Edit and Continue feature is useful for developer productivity, but can cause issues in compiler conformance, code size and performance. 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** cannot use **__LINE__** as a non-type template argument, although **__LINE__** can used in macro expansions. |
| 52 | + |
| 53 | +The **/ZI** option forces both the [/Gy (Enable Function-Level Linking)](../../build/reference/gy-enable-function-level-linking.md) and [/FC (Full Path of Source Code File in Diagnostics)](../../build/reference/fc-full-path-of-source-code-file-in-diagnostics.md) options to be used in your compilation. |
| 54 | + |
| 55 | +**/ZI** is not compatible with [/clr (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md). |
| 56 | + |
58 | 57 | > [!NOTE]
|
59 |
| -> **/ZI** is only available in the compilers targeting x86 and x64 processors; this compiler option is not available in the compilers targeting ARM processors. |
60 |
| - |
61 |
| - The compiler names the program database *project*.pdb. If you compile a file without a project, the compiler creates a database named VC*x*0.pdb., where *x* is the major version of [!INCLUDE[vcprvc](../../build/includes/vcprvc_md.md)] in use. The compiler embeds the name of the PDB in each .obj file created using this option, pointing the debugger to the location of symbolic and line-number information. When you use this option, your .obj files will be smaller, because debugging information is stored in the .pdb file rather than in .obj files. |
62 |
| - |
63 |
| - If you create a library from objects that were compiled using this option, the associated .pdb file must be available when the library is linked to a program. Thus, if you distribute the library, you must distribute the PDB. |
64 |
| - |
65 |
| - To create a library that contains debugging information without using .pdb files, you must select the compiler's C 7.0-Compatible (**/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. The **/Yd** option is ignored when the Program Database option is specified. |
66 |
| - |
67 |
| -### To set this compiler option in the Visual Studio development environment |
68 |
| - |
69 |
| -1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md). |
70 |
| - |
71 |
| -2. Click the **C/C++** folder. |
72 |
| - |
73 |
| -3. Click the **General** property page. |
74 |
| - |
75 |
| -4. Modify the **Debug Information Format** property. |
76 |
| - |
77 |
| -### To set this compiler option programmatically |
78 |
| - |
79 |
| -- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.DebugInformationFormat%2A>. |
80 |
| - |
81 |
| -## See Also |
82 |
| - [Compiler Options](../../build/reference/compiler-options.md) |
83 |
| - [Setting Compiler Options](../../build/reference/setting-compiler-options.md) |
| 58 | +> 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. |
| 59 | +
|
| 60 | +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*0.pdb, where *x* is the major version number of the Visual Studio version in use. The compiler embeds the name of the PDB in each .obj file created using this option, pointing the debugger to the location of symbolic and line-number information. When you use this option, your .obj files are smaller, because debugging information is stored in the .pdb file rather than in .obj files. |
| 61 | + |
| 62 | +If you create a library from objects that were compiled using this option, the associated .pdb file must be available when the library is linked to a program. Thus, if you distribute the library, you must distribute the PDB. |
| 63 | + |
| 64 | +To create a library that contains debugging information without using .pdb files, you must select the compiler's C 7.0-Compatible (**/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. The **/Yd** option is ignored when the Program Database option is specified. |
| 65 | + |
| 66 | +### To set this compiler option in the Visual Studio development environment |
| 67 | + |
| 68 | +1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md). |
| 69 | + |
| 70 | +1. Open the **Configuration Properties** > **C/C++** > **General** property page. |
| 71 | + |
| 72 | +1. Modify the **Debug Information Format** property. Choose **OK** to save your changes. |
| 73 | + |
| 74 | +### To set this compiler option programmatically |
| 75 | + |
| 76 | +- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.DebugInformationFormat%2A>. |
| 77 | + |
| 78 | +## See also |
| 79 | + |
| 80 | +[Compiler Options](../../build/reference/compiler-options.md) |
| 81 | +[Setting Compiler Options](../../build/reference/setting-compiler-options.md) |
| 82 | + |
0 commit comments