|
1 | 1 | ---
|
2 | 2 | title: "__thiscall"
|
3 |
| -ms.date: "11/04/2016" |
| 3 | +ms.date: "05/22/2020" |
4 | 4 | f1_keywords: ["__thiscall", "__thiscall_cpp"]
|
5 | 5 | helpviewer_keywords: ["__thiscall keyword [C++]"]
|
6 | 6 | ms.assetid: a6a22dd2-0101-4885-b33b-22f6057965df
|
7 | 7 | ---
|
8 |
| -# __thiscall |
| 8 | +# `__thiscall` |
9 | 9 |
|
10 |
| -**Microsoft Specific** |
| 10 | +The **Microsoft-specific** **`__thiscall`** calling convention is used on C++ class member functions on the x86 architecture. It's the default calling convention used by member functions that don't use variable arguments (`vararg` functions). |
11 | 11 |
|
12 |
| -The **__thiscall** calling convention is used on member functions and is the default calling convention used by C++ member functions that do not use variable arguments. Under **__thiscall**, the callee cleans the stack, which is impossible for `vararg` functions. Arguments are pushed on the stack from right to left, with the **this** pointer being passed via register ECX, and not on the stack, on the x86 architecture. |
| 12 | +Under **`__thiscall`**, the callee cleans the stack, which is impossible for `vararg` functions. Arguments are pushed on the stack from right to left. The **`this`** pointer is passed via register ECX, and not on the stack. |
13 | 13 |
|
14 |
| -One reason to use **__thiscall** is in classes whose member functions use `__clrcall` by default. In that case, you can use **__thiscall** to make individual member functions callable from native code. |
| 14 | +On ARM, ARM64, and x64 machines, **`__thiscall`** is accepted and ignored by the compiler. That's because they use a register-based calling convention by default. |
15 | 15 |
|
16 |
| -When compiling with [/clr:pure](../build/reference/clr-common-language-runtime-compilation.md), all functions and function pointers are `__clrcall` unless specified otherwise. The **/clr:pure** and **/clr:safe** compiler options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017. |
| 16 | +One reason to use **`__thiscall`** is in classes whose member functions use **`__clrcall`** by default. In that case, you can use **`__thiscall`** to make individual member functions callable from native code. |
17 | 17 |
|
18 |
| -In releases before Visual Studio 2005, the **__thiscall** calling convention could not be explicitly specified in a program, because **__thiscall** was not a keyword. |
| 18 | +When compiling with [**`/clr:pure`**](../build/reference/clr-common-language-runtime-compilation.md), all functions and function pointers are **`__clrcall`** unless specified otherwise. The **`/clr:pure`** and **`/clr:safe`** compiler options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017. |
19 | 19 |
|
20 |
| -`vararg` member functions use the **__cdecl** calling convention. All function arguments are pushed on the stack, with the **this** pointer placed on the stack last |
| 20 | +`vararg` member functions use the **`__cdecl`** calling convention. All function arguments are pushed on the stack, with the **`this`** pointer placed on the stack last. |
21 | 21 |
|
22 |
| -Because this calling convention applies only to C++, there is no C name decoration scheme. |
| 22 | +Because this calling convention applies only to C++, it doesn't have a C name decoration scheme. |
23 | 23 |
|
24 |
| -On ARM and x64 machines, **__thiscall** is accepted and ignored by the compiler. |
25 |
| - |
26 |
| -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. |
27 |
| - |
28 |
| -**END Microsoft Specific** |
| 24 | +When you define a non-static class member function out-of-line, specify the calling convention modifier only in the declaration. You don't have to specify it again on the out-of-line definition. The compiler uses the calling convention specified during declaration at the point of definition. |
29 | 25 |
|
30 | 26 | ## See also
|
31 | 27 |
|
32 |
| -[Argument Passing and Naming Conventions](../cpp/argument-passing-and-naming-conventions.md) |
| 28 | +[Argument passing and naming conventions](../cpp/argument-passing-and-naming-conventions.md) |
0 commit comments