You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/c-runtime-library/crt-initialization.md
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,6 @@ description: "Describes how the CRT initializes global state in native code."
4
4
ms.topic: "conceptual"
5
5
ms.date: 08/02/2021
6
6
helpviewer_keywords: ["CRT initialization [C++]"]
7
-
ms.assetid: e7979813-1856-4848-9639-f29c86b74ad7
8
7
---
9
8
# CRT initialization
10
9
@@ -16,9 +15,9 @@ It's possible, though not recommended, to take advantage of Microsoft-specific l
16
15
17
16
## Initializing a global object
18
17
19
-
Consider the following code:
18
+
Consider the following C++ code (C won't allow this code because it doesn't allow a function call in a constant expression).
20
19
21
-
```C
20
+
```cpp
22
21
intfunc(void)
23
22
{
24
23
return 3;
@@ -69,7 +68,6 @@ Offset Type Applied To Index Name
69
68
The CRT defines two pointers:
70
69
71
70
-`__xc_a` in `.CRT$XCA`
72
-
73
71
-`__xc_z` in `.CRT$XCZ`
74
72
75
73
Neither group has any other symbols defined except `__xc_a` and `__xc_z`.
@@ -88,7 +86,7 @@ The section should resemble this example:
88
86
__xc_z
89
87
```
90
88
91
-
So, the CRT library uses both `__xc_a` and `__xc_z` to determine the start and end of the global initializers list because of the way in which they're laid out in memory after the image is loaded.
89
+
The CRT library uses both `__xc_a` and `__xc_z` to determine the start and end of the global initializers list because of the way in which they're laid out in memory after the image is loaded.
92
90
93
91
## Linker features for initialization
94
92
@@ -112,4 +110,5 @@ The names `.CRT$XCT` and `.CRT$XCV` aren't used by either the compiler or the CR
@@ -14,10 +13,12 @@ The **`__fastcall`** calling convention specifies that arguments to functions ar
14
13
15
14
|Element|Implementation|
16
15
|-------------|--------------------|
17
-
|Argument-passing order|The first two DWORD or smaller arguments that are found in the argument list from left to right are passed in ECX and EDX registers; all other arguments are passed on the stack from right to left.|
16
+
|Argument-passing order|The first two `DWORD` or smaller arguments that are found in the argument list from left to right are passed in ECX and EDX registers; all other arguments are passed on the stack from right to left.|
18
17
|Stack-maintenance responsibility|Called function pops the arguments from the stack.|
19
18
|Name-decoration convention|At sign (\@) is prefixed to names; an at sign followed by the number of bytes (in decimal) in the parameter list is suffixed to names.|
20
19
|Case-translation convention|No case translation performed.|
20
+
|Classes, structs, and unions|Treated as "multibyte" types (regardless of size) and passed on the stack. |
21
+
|Enums and enum classes | Passed by register if their underlying type is passed by register. For example, if the underlying type is `int` or `unsigned int` of size 8, 16, or 32 bits. |
21
22
22
23
> [!NOTE]
23
24
> Future compiler versions may use different registers to store parameters.
@@ -26,7 +27,7 @@ Using the [/Gr](../build/reference/gd-gr-gv-gz-calling-convention.md) compiler o
26
27
27
28
The **`__fastcall`** keyword is accepted and ignored by the compilers that target ARM and x64 architectures; on an x64 chip, by convention, the first four arguments are passed in registers when possible, and additional arguments are passed on the stack. For more information, see [x64 Calling Convention](../build/x64-calling-convention.md). On an ARM chip, up to four integer arguments and eight floating-point arguments may be passed in registers, and additional arguments are passed on the stack.
28
29
29
-
For non-static class functions, if the function is defined out-of-line, the calling convention modifier does not have to be specified on the out-of-line definition. That is, for class non-static member methods, the calling convention specified during declaration is assumed at the point of definition. Given this class definition:
30
+
For nonstatic class functions, if the function is defined out-of-line, the calling convention modifier doesn't have to be specified on the out-of-line definition. That is, for class non-static member methods, the calling convention specified during declaration is assumed at the point of definition. Given this class definition:
30
31
31
32
```cpp
32
33
structCMyClass {
@@ -46,7 +47,7 @@ is equivalent to this:
46
47
void __fastcall CMyClass::mymethod() { return; }
47
48
```
48
49
49
-
For compatibility with previous versions, **_fastcall** is a synonym for **`__fastcall`** unless compiler option [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) is specified.
50
+
For compatibility with previous versions, **`_fastcall`** is a synonym for **`__fastcall`** unless compiler option [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) is specified.
0 commit comments