Skip to content

Commit 01cd3fa

Browse files
author
Colin Robertson
committed
Update keywords for single underscore versions
1 parent fafb009 commit 01cd3fa

8 files changed

+44
-37
lines changed

docs/build/calling-dll-functions-from-visual-basic-applications.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For Visual Basic applications (or applications in other languages such as Pascal
1717

1818
`__stdcall` creates the correct calling convention for the function (the called function cleans up the stack and parameters are passed from right to left) but decorates the function name differently. So, when **__declspec(dllexport)** is used on an exported function in a DLL, the decorated name is exported.
1919

20-
The `__stdcall` name decoration prefixes the symbol name with an underscore (_) and appends the symbol with an at sign (**\@**) character followed by the number of bytes in the argument list (the required stack space). As a result, the function when declared as:
20+
The `__stdcall` name decoration prefixes the symbol name with an underscore ( **\_** ) and appends the symbol with an at sign (**\@**) character followed by the number of bytes in the argument list (the required stack space). As a result, the function when declared as:
2121

2222
```C
2323
int __stdcall func (int a, double b)
@@ -29,7 +29,7 @@ The C calling convention (`__cdecl`) decorates the name as `_func`.
2929
3030
To get the decorated name, use [/MAP](../build/reference/map-generate-mapfile.md). Use of **__declspec(dllexport)** does the following:
3131
32-
- If the function is exported with the C calling convention (**_cdecl**), it strips the leading underscore (_) when the name is exported.
32+
- If the function is exported with the C calling convention (`__cdecl`), it strips the leading underscore ( **\_** ) when the name is exported.
3333
3434
- If the function being exported does not use the C calling convention (for example, `__stdcall`), it exports the decorated name.
3535

docs/build/reference/gh-enable-penter-hook-function.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The `_penter` function is not part of any library and it is up to you to provide
2929
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:
3030

3131
```
32-
void __declspec(naked) _cdecl _penter( void );
32+
void __declspec(naked) __cdecl _penter( void );
3333
```
3434

3535
This declaration is not available for 64-bit projects.
@@ -52,7 +52,7 @@ This declaration is not available for 64-bit projects.
5252

5353
The following code, when compiled with **/Gh**, shows how `_penter` is called twice; once when entering function `main` and once when entering function `x`.
5454

55-
```
55+
```cpp
5656
// Gh_compiler_option.cpp
5757
// compile with: /Gh
5858
// processor: x86
@@ -63,7 +63,7 @@ int main() {
6363
x();
6464
}
6565

66-
extern "C" void __declspec(naked) _cdecl _penter( void ) {
66+
extern "C" void __declspec(naked) __cdecl _penter( void ) {
6767
_asm {
6868
push eax
6969
push ebx

docs/build/reference/gh-enable-pexit-hook-function.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The `_pexit` function is not part of any library and it is up to you to provide
2929
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:
3030

3131
```
32-
void __declspec(naked) _cdecl _pexit( void );
32+
void __declspec(naked) __cdecl _pexit( void );
3333
```
3434

3535
`_pexit` is similar to `_penter`; see [/Gh (Enable _penter Hook Function)](../../build/reference/gh-enable-penter-hook-function.md) for an example of how to write a `_pexit` function.

docs/build/reference/optimization-pragmas-and-keywords.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Several keywords and pragmas that you use in your C or C++ code affect optimizat
1919

2020
- [__assume](../../intrinsics/assume.md)
2121

22-
- [inline, _inline, or \__forceinline](../../cpp/inline-functions-cpp.md)
22+
- [inline, __inline, or \__forceinline](../../cpp/inline-functions-cpp.md)
2323

2424
- [#pragma auto_inline](../../preprocessor/auto-inline.md)
2525

docs/c-language/c-keywords.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "C Keywords | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/09/2018"
55
ms.technology: ["cpp-language"]
66
ms.topic: "language-reference"
77
dev_langs: ["C++"]
@@ -36,17 +36,19 @@ The following keywords and special identifiers are recognized by the Microsoft C
3636

3737
|||||
3838
|-|-|-|-|
39-
|**__asm**|**dllimport**<sup>2</sup>|**__int8**|**naked**<sup>2</sup>|
40-
|**__based**<sup>1</sup>|**__except**|**__int16**|**__stdcall**|
41-
|**__cdecl**|**__fastcall**|**__int32**|**thread**<sup>2</sup>|
42-
|**__declspec**|**__finally**|**__int64**|**__try**|
43-
|**dllexport**<sup>2</sup>|**__inline**|**__leave**||
39+
|**__asm**<sup>3</sup>|**dllimport**<sup>2</sup>|**__int8**<sup>3</sup>|**naked**<sup>2</sup>|
40+
|**__based**<sup>1, 3</sup>|**__except**<sup>3</sup>|**__int16**<sup>3</sup>|**__stdcall**<sup>3</sup>|
41+
|**__cdecl**<sup>3</sup>|**__fastcall**|**__int32**<sup>3</sup>|**thread**<sup>2</sup>|
42+
|**__declspec**<sup>3</sup>|**__finally**<sup>3</sup>|**__int64**<sup>3</sup>|**__try**<sup>3</sup>|
43+
|**dllexport**<sup>2</sup>|**__inline**<sup>3</sup>|**__leave**<sup>3</sup>||
4444

4545
<sup>1</sup> The **__based** keyword has limited uses for 32-bit and 64-bit target compilations.
4646

4747
<sup>2</sup> These are special identifiers when used with **__declspec**; their use in other contexts is not restricted.
4848

49-
Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the /Za option (compile for ANSI compatibility) during compilation. When you do this, Microsoft-specific keywords are disabled.
49+
<sup>3</sup> For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
50+
51+
Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you do this, some Microsoft-specific keywords are disabled.
5052

5153
When Microsoft extensions are enabled, you can use the keywords listed above in your programs. For ANSI compliance, most of these keywords are prefaced by a double underscore. The four exceptions, **dllexport**, **dllimport**, **naked**, and **thread**, are used only with **__declspec** and therefore do not require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.
5254

docs/cpp/cdecl.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: "__cdecl | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/09/2018"
55
ms.technology: ["cpp-language"]
66
ms.topic: "language-reference"
7-
f1_keywords: ["__cdecl_cpp"]
7+
f1_keywords: ["__cdecl_cpp", "__cdecl", "_cdecl" ]
88
dev_langs: ["C++"]
99
helpviewer_keywords: ["__cdecl keyword [C++]"]
1010
ms.assetid: 1ff1d03e-fb4e-4562-8be1-74f1ad6427f1
@@ -52,6 +52,8 @@ is equivalent to this:
5252
void __cdecl CMyClass::mymethod() { return; }
5353
```
5454
55+
For compatibility with previous versions, **_cdecl** is a synonym for **__cdecl** unless compiler option [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) is specified.
56+
5557
## Example
5658
5759
In the following example, the compiler is instructed to use C naming and calling conventions for the `system` function.

docs/cpp/inline-functions-cpp.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Using inline functions can make your program faster because they eliminate the o
7171
7272
The compiler treats the inline expansion options and keywords as suggestions. There is no guarantee that functions will be inlined. You cannot force the compiler to inline a particular function, even with the **__forceinline** keyword. When compiling with **/clr**, the compiler will not inline a function if there are security attributes applied to the function.
7373
74-
The **inline** keyword is available only in C++. The **__inline** and **__forceinline** keywords are available in both C and C++. For compatibility with previous versions, **_inline** is a synonym for **__inline**.
74+
The **inline** keyword is available only in C++. The **__inline** and **__forceinline** keywords are available in both C and C++. For compatibility with previous versions, **_inline** is a synonym for **__inline** unless compiler option [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) is specified.
7575
7676
The **inline** keyword tells the compiler that inline expansion is preferred. However, the compiler can create a separate instance of the function (instantiate) and create standard calling linkages instead of inserting the code inline. Two cases where this can happen are:
7777

docs/cpp/keywords-cpp.md

+23-20
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ Keywords are predefined reserved identifiers that have special meanings. They ca
1717

1818
|||||
1919
|-|-|-|-|
20-
|[__abstract](../dotnet/declaration-of-a-managed-class-type.md) <sup>2</sup>|[__alignof Operator](alignof-operator.md)|[__asm](../assembler/inline/asm.md)|[__assume](../intrinsics/assume.md)|
21-
|[__based](based-pointers-cpp.md)|[__box](../dotnet/value-type-semantics.md) <sup>2</sup>|[__cdecl](cdecl.md)|[__declspec](declspec.md)|
22-
|[__delegate](../dotnet/delegates-and-events.md) <sup>2</sup>|[__event](event.md)|[__except](try-except-statement.md)|[__fastcall](fastcall.md)|
23-
|[__finally](try-finally-statement.md)|[__forceinline](inline-functions-cpp.md)|[__gc](../dotnet/declaration-of-a-clr-reference-class-object.md) <sup>2</sup>|[__hook](hook.md) <sup>3</sup>|
24-
|[__identifier](../windows/identifier-cpp-cli.md)|[__if_exists](if-exists-statement.md)|[__if_not_exists](if-not-exists-statement.md)|[__inline](inline-functions-cpp.md)|
25-
|[__int16](int8-int16-int32-int64.md)|[__int32](int8-int16-int32-int64.md)|[__int64](int8-int16-int32-int64.md)|[__int8](int8-int16-int32-int64.md)|
26-
|[__interface](interface.md)|[__leave](try-finally-statement.md)|[__m128](m128.md)|[__m128d](m128d.md)|
27-
|[__m128i](m128i.md)|[__m64](m64.md)|[__multiple_inheritance](inheritance-keywords.md)|[__nogc](../dotnet/declaration-of-a-clr-reference-class-object.md) <sup>2</sup>|
28-
|[__noop](../intrinsics/noop.md)|**__pin** <sup>2</sup>|**__property** <sup>2</sup>|[__raise](raise.md)|
29-
|**__sealed** <sup>2</sup>|[__single_inheritance](inheritance-keywords.md)|[__stdcall](stdcall.md)|[__super](super.md)|
30-
|[__thiscall](thiscall.md)|[__try/\__except](try-except-statement.md)|[__try/\__finally](try-finally-statement.md)|[__try_cast](../dotnet/cast-notation-and-introduction-of-safe-cast-angles.md) <sup>2</sup>|
31-
|[__unaligned](unaligned.md)|[__unhook](unhook.md) <sup>3</sup>|[__uuidof](uuidof-operator.md)|[__value](../dotnet/value-type-semantics.md) <sup>2</sup>|
32-
|[__virtual_inheritance](inheritance-keywords.md)|[__w64](w64.md)|[__wchar_t](fundamental-types-cpp.md)|[abstract](../windows/abstract-cpp-component-extensions.md)|
20+
|[__abstract](../dotnet/declaration-of-a-managed-class-type.md) <sup>2</sup>|[__alignof Operator](alignof-operator.md) <sup>4</sup>|[__asm](../assembler/inline/asm.md)<sup>4</sup>|[__assume](../intrinsics/assume.md) <sup>4</sup>|
21+
|[__based](based-pointers-cpp.md) <sup>4</sup>|[__box](../dotnet/value-type-semantics.md) <sup>2</sup>|[__cdecl](cdecl.md) <sup>4</sup>|[__declspec](declspec.md) <sup>4</sup>|
22+
|[__delegate](../dotnet/delegates-and-events.md) <sup>2</sup>|[__event](event.md)|[__except](try-except-statement.md) <sup>4</sup>|[__fastcall](fastcall.md) <sup>4</sup>|
23+
|[__finally](try-finally-statement.md) <sup>4</sup>|[__forceinline](inline-functions-cpp.md) <sup>4</sup>|[__gc](../dotnet/declaration-of-a-clr-reference-class-object.md) <sup>2</sup>|[__hook](hook.md) <sup>3</sup>|
24+
|[__identifier](../windows/identifier-cpp-cli.md)|[__if_exists](if-exists-statement.md)|[__if_not_exists](if-not-exists-statement.md)|[__inline](inline-functions-cpp.md) <sup>4</sup>|
25+
|[__int16](int8-int16-int32-int64.md) <sup>4</sup>|[__int32](int8-int16-int32-int64.md) <sup>4</sup>|[__int64](int8-int16-int32-int64.md) <sup>4</sup>|[__int8](int8-int16-int32-int64.md) <sup>4</sup>|
26+
|[__interface](interface.md)|[__leave](try-finally-statement.md) <sup>4</sup>|[__m128](m128.md)|[__m128d](m128d.md)|
27+
|[__m128i](m128i.md)|[__m64](m64.md)|[__multiple_inheritance](inheritance-keywords.md) <sup>4</sup>|[__nogc](../dotnet/declaration-of-a-clr-reference-class-object.md) <sup>2</sup>|
28+
|[__noop](../intrinsics/noop.md)|**__pin** <sup>2</sup>|**__property** <sup>2</sup>|[__ptr32](ptr32-ptr64.md) <sup>4</sup>|
29+
|[__ptr64](ptr32-ptr64.md)<sup>4</sup>|[__raise](raise.md)|[__restrict](extension-restrict.md) <sup>4</sup>|**__sealed** <sup>2</sup>|
30+
|[__single_inheritance](inheritance-keywords.md)<sup>4</sup>|[__sptr](sptr-uptr.md)<sup>4</sup>|[__stdcall](stdcall.md) <sup>4</sup>|[__super](super.md)|
31+
|[__thiscall](thiscall.md)|[__try/\__except](try-except-statement.md) <sup>4</sup>|[__try/\__finally](try-finally-statement.md) <sup>4</sup>|[__try_cast](../dotnet/cast-notation-and-introduction-of-safe-cast-angles.md) <sup>2</sup>|
32+
|[__unaligned](unaligned.md) <sup>4</sup>|[__unhook](unhook.md) <sup>3</sup>|[__uptr](sptr-uptr.md) <sup>4</sup>|[__uuidof](uuidof-operator.md) <sup>4</sup>|
33+
|[__value](../dotnet/value-type-semantics.md) <sup>2</sup>|[__vectorcall](vectorcall.md) <sup>4</sup>|[__virtual_inheritance](inheritance-keywords.md) <sup>4</sup>|[__w64](w64.md) <sup>4</sup>|
34+
|[__wchar_t](fundamental-types-cpp.md)|||[abstract](../windows/abstract-cpp-component-extensions.md)|
3335
|[alignas](align-cpp.md)|[array](../windows/arrays-cpp-component-extensions.md)|[auto](auto-keyword.md)|[bool](bool-cpp.md)|
3436
|[break](break-statement-cpp.md)|[case](switch-statement-cpp.md)|[catch](try-throw-and-catch-statements-cpp.md)|[char](fundamental-types-cpp.md)|
3537
|[char16_t](char-wchar-t-char16-t-char32-t.md)|[char32_t](char-wchar-t-char16-t-char32-t.md)|[class](class-cpp.md)|[const](const-cpp.md)|
@@ -58,22 +60,23 @@ Keywords are predefined reserved identifiers that have special meanings. They ca
5860
|[value struct](../windows/classes-and-structs-cpp-component-extensions.md)|[virtual](virtual-cpp.md)|[void](void-cpp.md)|[volatile](volatile-cpp.md)|
5961
|[while](while-statement-cpp.md)|
6062

63+
<sup>1</sup> Extended attributes for the **__declspec** keyword.
6164

62-
1 Extended attributes for the **__declspec** keyword.
65+
<sup>2</sup> Applicable to Managed Extensions for C++ only. This syntax is now deprecated. See [Component Extensions for Runtime Platforms](../windows/component-extensions-for-runtime-platforms.md) for more information.
6366

64-
2 Applicable to Managed Extensions for C++ only. This syntax is now deprecated.
6567

66-
3 Intrinsic function used in event handling.
6768

68-
See [Component Extensions for Runtime Platforms](../windows/component-extensions-for-runtime-platforms.md) for more information.
69+
<sup>3</sup> Intrinsic function used in event handling.
6970

70-
## Microsoft Specific
71+
<sup>4</sup> For backward compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled (the default).
72+
73+
**Microsoft Specific**
7174

7275
In Microsoft C++, identifiers with two leading underscores are reserved for compiler implementations. Therefore, the Microsoft convention is to precede Microsoft-specific keywords with double underscores. These words cannot be used as identifier names.
7376

74-
Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the ANSI-compatible [/Za](../build/reference/za-ze-disable-language-extensions.md) command-line option (compile for ANSI compatibility) during compilation. When you do this, Microsoft-specific keywords are disabled.
77+
Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you do this, some Microsoft-specific keywords are disabled.
7578

76-
When Microsoft extensions are enabled, you can use the Microsoft-specific keywords in your programs. For ANSI compliance, these keywords are prefaced by a double underscore. For backward compatibility, single-underscore versions of all the double-underscored keywords except **__except**, **__finally**, **__leave**, and **__try** are supported. In addition, **__cdecl** is available with no leading underscore.
79+
When Microsoft extensions are enabled, you can use the Microsoft-specific keywords in your programs. For ANSI compliance, these keywords are prefaced by a double underscore. For backward compatibility, single-underscore versions of many of the double-underscored keywords are supported. In addition, **__cdecl** is available with no leading underscore.
7780

7881
The **__asm** keyword replaces C++ `asm` syntax. `asm` is reserved for compatibility with other C++ implementations, but not implemented. Use **__asm**.
7982

0 commit comments

Comments
 (0)