Skip to content

Commit 70f19b4

Browse files
committed
draft
1 parent 12125b2 commit 70f19b4

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

docs/cpp/declspec.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
description: "Learn more about: `__declspec`"
33
title: "__declspec"
4-
ms.date: 03/01/2022
4+
ms.date: 1/14/2025
55
f1_keywords: ["__declspec_cpp", "__declspec", "_declspec"]
66
helpviewer_keywords: ["__declspec keyword [C++]"]
77
---
88
# `__declspec`
99

1010
**Microsoft Specific**
1111

12-
The extended attribute syntax for specifying storage-class information uses the **`__declspec`** keyword, which specifies that an instance of a given type is to be stored with a Microsoft-specific storage-class attribute listed below. Examples of other storage-class modifiers include the **`static`** and **`extern`** keywords. However, these keywords are part of the ANSI specification of the C and C++ languages, and as such aren't covered by extended attribute syntax. The extended attribute syntax simplifies and standardizes Microsoft-specific extensions to the C and C++ languages.
12+
The extended attribute syntax for specifying storage-class information uses the `__declspec` keyword, which specifies that an instance of a given type is to be stored with a Microsoft-specific storage-class attribute listed below. Examples of other storage-class modifiers include the `static` and `extern` keywords. However, these keywords are part of the ANSI specification of the C and C++ languages, and as such aren't covered by extended attribute syntax. The extended attribute syntax simplifies and standardizes Microsoft-specific extensions to the C and C++ languages.
1313

1414
## Grammar
1515

@@ -30,6 +30,7 @@ The extended attribute syntax for specifying storage-class information uses the
3030
 **`dllimport`**\
3131
 **`dllexport`**\
3232
 **`empty_bases`**\
33+
 **`hybrid_patchable`**\
3334
 **`jitintrinsic`**\
3435
 **`naked`**\
3536
 **`noalias`**\

docs/cpp/hybrid-patchable.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
description: "Learn more about: hybrid_patchable (C++)"
3+
title: "hybrid_patchable (C++)"
4+
ms.date: 1/15/2025
5+
f1_keywords: ["hybrid_patchable"]
6+
helpviewer_keywords: ["__declspec keyword [C++], hybrid_patchable", "hybrid_patchable __declspec keyword"]
7+
---
8+
# `hybrid_patchable` (C++)
9+
10+
**Microsoft Specific**
11+
12+
Use **`__declspec(hybrid_patchable)`** extended attribute which can be used in the declaration of functions.
13+
14+
## Syntax
15+
16+
> `__declspec(hybrid_patchable)`
17+
18+
## Remarks
19+
20+
We recommend that all new code use the [`noexcept`](noexcept-cpp.md) operator rather than `__declspec(nothrow)`.
21+
22+
This attribute tells the compiler that the declared function and the functions it calls never throw an exception. However, it does not enforce the directive. In other words, it never causes [`std::terminate`](../standard-library/exception-functions.md#terminate) to be invoked, unlike **`noexcept`**, or in **`std:c++17`** mode (Visual Studio 2017 version 15.5 and later), `throw()`.
23+
24+
With the synchronous exception handling model, now the default, the compiler can eliminate the mechanics of tracking the lifetime of certain unwindable objects in such a function, and significantly reduce the code size. Given the following preprocessor directive, the three function declarations below are equivalent in **`/std:c++14`** mode:
25+
26+
```cpp
27+
__declspec(hybrid_patchable) int Example() {
28+
return 1;
29+
}
30+
```
31+
32+
Generates the following fast-forward sequence:
33+
34+
```
35+
EXP+#Example:
36+
00000001400CE000: 48 8B C4 mov rax,rsp
37+
00000001400CE003: 48 89 58 20 mov qword ptr [rax+20h],rbx
38+
00000001400CE007: 55 push rbp
39+
00000001400CE008: 5D pop rbp
40+
00000001400CE009: E9 BA 7A F3 FF jmp #Example
41+
00000001400CE00E: CC int 3
42+
00000001400CE00F: CC int 3
43+
```
44+
45+
46+
In **`/std:c++17`** mode, `throw()` is not equivalent to the others that use `__declspec(nothrow)` because it causes `std::terminate` to be invoked if an exception is thrown from the function.
47+
48+
The `void __stdcall f3() throw();` declaration uses the syntax defined by the C++ standard. In C++17 the `throw()` keyword was deprecated.
49+
50+
**END Microsoft Specific**
51+
52+
## See also
53+
54+
[`__declspec`](../cpp/declspec.md)\
55+
[`noexcept`](noexcept-cpp.md)\
56+
[Keywords](../cpp/keywords-cpp.md)

docs/cpp/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ items:
696696
href: ../cpp/using-dllimport-and-dllexport-in-cpp-classes.md
697697
- name: empty_bases
698698
href: ../cpp/empty-bases.md
699+
- name: hybrid_patchable
700+
href: ../cpp/hybrid-patchable.md
699701
- name: jitintrinsic
700702
href: ../cpp/jitintrinsic.md
701703
- name: naked

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy