Skip to content

Commit 3641edd

Browse files
authored
Merge pull request #2974 from corob-msft/docs/corob/2278
Update docs for /Gh, /GH per 2278
2 parents fa2a2d7 + bc049ec commit 3641edd

File tree

2 files changed

+47
-38
lines changed

2 files changed

+47
-38
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)

0 commit comments

Comments
 (0)