Skip to content

Commit fcf8a28

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#2297 from MicrosoftDocs/master637297416028655245
Fix git push error for protected CLA branch
2 parents 7468cdb + b2a2f34 commit fcf8a28

File tree

6 files changed

+270
-181
lines changed

6 files changed

+270
-181
lines changed
Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,52 @@
11
---
2-
title: "/Gh (Enable _penter Hook Function)"
3-
ms.date: "11/04/2016"
2+
title: "/Gh (Enable _penter hook function)"
3+
description: "Describes the /Gh compiler option to call the supplied _penter function."
4+
ms.date: "07/06/2020"
45
f1_keywords: ["_penter"]
56
helpviewer_keywords: ["/Gh compiler option [C++]", "Gh compiler option [C++]", "_penter function", "-Gh compiler option [C++]"]
67
ms.assetid: 1510a082-8a0e-486e-a309-6add814b494f
78
---
8-
# /Gh (Enable _penter Hook Function)
9+
# /Gh (Enable _penter hook function)
910

1011
Causes a call to the `_penter` function at the start of every method or function.
1112

1213
## Syntax
1314

14-
```
15-
/Gh
16-
```
15+
> **`/Gh`**
1716
1817
## Remarks
1918

20-
The `_penter` function is not part of any library and it is up to you to provide a definition for `_penter`.
19+
The `_penter` function isn't part of any library. It's up to you to provide a definition for `_penter`.
2120

22-
Unless you plan to explicitly call `_penter`, you do not need to provide a prototype. The function must appear as if it had the following prototype, and it must push the content of all registers on entry and pop the unchanged content on exit:
21+
Unless you plan to explicitly call `_penter`, you don't need to provide a prototype. The function must push the content of all registers on entry and pop the unchanged content on exit. It must appear as if it had the following prototype:
2322

2423
```cpp
2524
void __declspec(naked) __cdecl _penter( void );
2625
```
2726
28-
This declaration is not available for 64-bit projects.
27+
This declaration isn't available for 64-bit projects.
2928
3029
### To set this compiler option in the Visual Studio development environment
3130
3231
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
3332
34-
1. Click the **C/C++** folder.
35-
36-
1. Click the **Command Line** property page.
33+
1. Open the **Configuration Properties** > **C/C++** > **Command Line** property page.
3734
38-
1. Type the compiler option in the **Additional Options** box.
35+
1. Enter the compiler option in the **Additional Options** box.
3936
4037
### To set this compiler option programmatically
4138
4239
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
4340
4441
## Example
4542
46-
The following code, when compiled with **/Gh**, shows how `_penter` is called twice; once when entering function `main` and once when entering function `x`.
43+
The following code, when compiled with **/Gh**, shows how `_penter` is called twice; once when entering function `main` and once when entering function `x`. The example consists of two source files, which you compile separately.
4744
4845
```cpp
49-
// Gh_compiler_option.cpp
50-
// compile with: /Gh
46+
// local_penter.cpp
47+
// compile with: cl /EHsc /c local_penter.cpp
5148
// processor: x86
5249
#include <stdio.h>
53-
void x() {}
54-
55-
int main() {
56-
x();
57-
}
5850
5951
extern "C" void __declspec(naked) __cdecl _penter( void ) {
6052
_asm {
@@ -82,12 +74,29 @@ extern "C" void __declspec(naked) __cdecl _penter( void ) {
8274
}
8375
```
8476

77+
```cpp
78+
// Gh_compiler_option.cpp
79+
// compile with: cl /EHsc /Gh Gh_compiler_option.cpp local_penter.obj
80+
// processor: x86
81+
#include <stdio.h>
82+
83+
void x() {}
84+
85+
int main() {
86+
x();
87+
}
88+
```
89+
90+
When run, the local `_penter` function is called on entry to `main` and `x`:
91+
8592
```Output
93+
8694
In a function!
8795
In a function!
8896
```
8997

9098
## See also
9199

92-
[MSVC Compiler Options](compiler-options.md)<br/>
93-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
100+
[MSVC compiler options](compiler-options.md)<br/>
101+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)<br/>
102+
[`/GH` (Enable _pexit hook function)](gh-enable-pexit-hook-function.md)
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
---
2-
title: "/GH (Enable _pexit Hook Function)"
3-
ms.date: "11/04/2016"
2+
title: "/GH (Enable _pexit hook function)"
3+
description: "Describes the /GH compiler option to set a local _pexit hook function."
4+
ms.date: "07/06/2020"
45
f1_keywords: ["_pexit"]
56
helpviewer_keywords: ["/Gh compiler option [C++]", "Gh compiler option [C++]", "_pexit function", "-Gh compiler option [C++]"]
67
ms.assetid: 93181453-2676-42e5-bf63-3b19e07299b6
78
---
8-
# /GH (Enable _pexit Hook Function)
9+
# /GH (Enable _pexit hook function)
910

1011
Calls the `_pexit` function at the end of every method or function.
1112

1213
## Syntax
1314

14-
```
15-
/GH
16-
```
15+
> **`/GH`**
1716
1817
## Remarks
1918

20-
The `_pexit` function is not part of any library and it is up to you to provide a definition for `_pexit`.
19+
The `_pexit` function isn't part of any library. It's up to you to provide a definition for `_pexit`.
2120

22-
Unless you plan to explicitly call `_pexit`, you do not need to provide a prototype. The function must appear as if it had the following prototype, and it must push the content of all registers on entry and pop the unchanged content on exit:
21+
Unless you plan to explicitly call `_pexit`, you don't need to provide a prototype. The function must push the content of all registers on entry and pop the unchanged content on exit. It must appear as if it had the following prototype:
2322

2423
```cpp
2524
void __declspec(naked) __cdecl _pexit( void );
2625
```
2726
28-
`_pexit` is similar to `_penter`; see [/Gh (Enable _penter Hook Function)](gh-enable-penter-hook-function.md) for an example of how to write a `_pexit` function.
27+
This declaration isn't available for 64-bit projects.
28+
29+
`_pexit` is similar to `_penter`; see [`/Gh` (Enable _penter Hook Function)](gh-enable-penter-hook-function.md) for an example of how to write a `_penter` function.
2930
3031
### To set this compiler option in the Visual Studio development environment
3132
3233
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
3334
34-
1. Click the **C/C++** folder.
35-
36-
1. Click the **Command Line** property page.
35+
1. Open the **Configuration Properties** > **C/C++** > **Command Line** property page.
3736
38-
1. Type the compiler option in the **Additional Options** box.
37+
1. Enter the compiler option in the **Additional Options** box.
3938
4039
### To set this compiler option programmatically
4140
4241
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
4342
4443
## See also
4544
46-
[MSVC Compiler Options](compiler-options.md)<br/>
47-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
45+
[MSVC compiler options](compiler-options.md)<br/>
46+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)<br/>
47+
[`/Gh` (Enable _penter hook function)](gh-enable-penter-hook-function.md)
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)