Skip to content

Commit 7570b42

Browse files
authored
Merge pull request #5596 from MicrosoftDocs/main
6/13/2024 AM Publish
2 parents 3669e6f + eafc892 commit 7570b42

File tree

9 files changed

+113
-61
lines changed

9 files changed

+113
-61
lines changed

docs/build/reference/arch-arm64.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ Specifies the Armv9-A architecture, where **`x`** is a required extension value
2222

2323
## Remarks
2424

25-
You may specify an ARM64 extension from Armv8.0-A through Armv8.9-A, and Armv9.0-A through Armv9.4-A. Optionally, enable one or more architecture features by appending a feature argument to the option<sup>3</sup>. For example, to target Armv8.0-A and enable feature `FEAT_LSE`, append feature argument **`lse`** so that the option becomes **`/arch:armv8.0+lse`**. For more information about available features and their requirements, see [`/feature` (ARM64)](feature-arm64.md)<sup>3</sup>.
25+
You can specify an ARM64 extension from Armv8.0-A through Armv8.9-A, and Armv9.0-A through Armv9.4-A. Optionally, enable one or more architecture features by appending a feature argument to the option<sup>3</sup>. For example, to target Armv8.0-A and enable feature `FEAT_LSE`, append feature argument **`lse`** so that the option becomes **`/arch:armv8.0+lse`**. For more information about available features and their requirements, see [`/feature` (ARM64)](feature-arm64.md)<sup>3</sup>.
2626

2727
> [!NOTE]
2828
> Depending on your version of Visual Studio, the compiler may not yet generate instructions from all feature sets required by the extension level you specify. For example, **`/arch:armv8.1`** allows the `*Interlocked*` intrinsic functions to use the appropriate atomic instruction introduced with the Armv8.1-A extension feature `FEAT_LSE`, but compiler support requires Visual Studio 2022 version 17.2 or later.
2929
30-
The `_M_ARM64` macro is defined by default when compiling for an ARM64 target. For more information, see [Predefined macros](../../preprocessor/predefined-macros.md).
30+
The `_M_ARM64` macro is defined by default when compiling for an ARM64 target. For more information, see [Predefined macros](../../preprocessor/predefined-macros.md)\
31+
32+
The `__ARM_ARCH` macro is defined for `/arch:ARMv8.0` and higher. It indicates the ARM architecture extension level that the compiler is targeting. For more information, see [Predefined macros](../../preprocessor/predefined-macros.md).
33+
34+
```cpp
35+
#if __ARM_ARCH >= 802
36+
// code that requires ARMv8.2...
37+
#endif
38+
```
3139

3240
**`/arch`** only affects code generation for native functions. When you use [`/clr`](clr-common-language-runtime-compilation.md) to compile, **`/arch`** has no effect on code generation for managed functions.
3341

@@ -50,5 +58,6 @@ The `_M_ARM64` macro is defined by default when compiling for an ARM64 target. F
5058
## See also
5159

5260
[`/arch` (Minimum CPU architecture)](arch-minimum-cpu-architecture.md)\
61+
[Predefined macros](../../preprocessor/predefined-macros.md)\
5362
[MSVC compiler options](compiler-options.md)\
5463
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/build/reference/link-repro-full-path-rsp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The linker produces `test.rsp` containing the following lines to reflect the ful
3838

3939
### To set this linker option programmatically
4040

41-
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AssemblyDebug%2A>.
41+
- See [VCLinkerTool.AdditionalOptions](/dotnet/api/microsoft.visualstudio.vcprojectengine.vclinkertool.additionaloptions)
4242

4343
## See also
4444

docs/build/reference/linker-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "MSVC Linker options"
33
description: "A list of the options supported by the Microsoft LINK linker."
4-
ms.date: 06/03/2024
4+
ms.date: 06/10/2024
55
f1_keywords: ["link"]
66
helpviewer_keywords: ["linker [C++]", "linker [C++], options listed", "libraries [C++], linking to COFF", "LINK tool [C++], linker options"]
77
---
@@ -78,7 +78,7 @@ You can use the [`comment`](../../preprocessor/comment-c-cpp.md) pragma to speci
7878
| [`/LARGEADDRESSAWARE`](largeaddressaware-handle-large-addresses.md) | Tells the compiler that the application supports addresses larger than 2 gigabytes |
7979
| [`/LIBPATH`](libpath-additional-libpath.md) | Specifies a path to search before the environmental library path. |
8080
| [`/LINKREPRO`](linkrepro.md) | Specifies a path to generate link repro artifacts in. |
81-
| [`LINKREPROFULLPATHRSP`](link-repro-full-path-rsp.md) | Generates a response file containing the absolute paths to all the files that the linker took as input. |
81+
| [`/LINKREPROFULLPATHRSP`](link-repro-full-path-rsp.md) | Generates a response file containing the absolute paths to all the files that the linker took as input. |
8282
| [`/LINKREPROTARGET`](linkreprotarget.md) | Generates a link repro only when producing the specified target.<sup>16.1</sup> |
8383
| [`/LTCG`](ltcg-link-time-code-generation.md) | Specifies link-time code generation. |
8484
| [`/MACHINE`](machine-specify-target-platform.md) | Specifies the target platform. |

docs/build/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,6 @@ items:
640640
href: ../build/reference/kernel-create-kernel-mode-binary.md
641641
- name: /link (Pass options to linker)
642642
href: ../build/reference/link-pass-options-to-linker.md
643-
- name: /LINKREPROFULLPATHRSP (Generate file containing absolute paths of linked files)
644-
href: ../build/reference/link-repro-full-path-rsp.md
645643
- name: /LN (Create MSIL module)
646644
href: ../build/reference/ln-create-msil-module.md
647645
- name: /MD, /MT, /LD (Use Run-time library)
@@ -1027,6 +1025,8 @@ items:
10271025
href: ../build/reference/libpath-additional-libpath.md
10281026
- name: /LINKREPRO (Link repro directory name)
10291027
href: ../build/reference/linkrepro.md
1028+
- name: /LINKREPROFULLPATHRSP (Generate file containing absolute paths of linked files)
1029+
href: ../build/reference/link-repro-full-path-rsp.md
10301030
- name: /LINKREPROTARGET (Link repro file name)
10311031
href: ../build/reference/linkreprotarget.md
10321032
- name: /LTCG (Link-time code generation)

docs/cpp/casting.md

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,78 @@
11
---
2-
description: "Learn more about: Casting"
2+
description: "Learn more about: Casting in C++"
33
title: "Casting"
4-
ms.date: "11/19/2018"
4+
ms.date: 6/11/2024
55
helpviewer_keywords: ["casting [C++]", "coercion [C++]", "virtual functions [C++], in derived classes [C++]", "static cast operator", "dynamic cast operator", "polymorphic classes [C++]", "classes [C++], polymorphism"]
6-
ms.assetid: 3dbeb06e-2f4b-4693-832d-624bc8ec95de
6+
ai-usage: ai-assisted
77
---
88
# Casting
99

10-
The C++ language provides that if a class is derived from a base class containing virtual functions, a pointer to that base class type can be used to call the implementations of the virtual functions residing in the derived class object. A class containing virtual functions is sometimes called a "polymorphic class."
10+
In C++, if a class is derived from a base class containing one or more virtual functions, a pointer to that base class type can be used to call virtual functions in the derived class object. A class containing virtual functions is sometimes called a "polymorphic class."
1111

12-
Since a derived class completely contains the definitions of all the base classes from which it is derived, it is safe to cast a pointer up the class hierarchy to any of these base classes. Given a pointer to a base class, it might be safe to cast the pointer down the hierarchy. It is safe if the object being pointed to is actually of a type derived from the base class. In this case, the actual object is said to be the "complete object." The pointer to the base class is said to point to a "subobject" of the complete object. For example, consider the class hierarchy shown in the following figure.
13-
14-
![Diagram of a class hierarchy where C derives from B, which derives from A.](../cpp/media/vc38zz1.gif "Class hierarchy") <br/>
12+
![Diagram of a class hierarchy where C derives from B, which derives from A.](../cpp/media/vc38zz1.gif "Class hierarchy")<br/>
1513
Class hierarchy
1614

17-
An object of type `C` could be visualized as shown in the following figure.
15+
An object of type `C` can be visualized as follows:
1816

1917
![Diagram of Class C with subobjects B and A.](../cpp/media/vc38zz2.gif "Class C with subobjects B and A") <br/>
20-
Class C with sub-objects B and A
18+
Class C with subobjects B and A
2119

22-
Given an instance of class `C`, there is a `B` subobject and an `A` subobject. The instance of `C`, including the `A` and `B` subobjects, is the "complete object."
20+
Given an instance of class `C`, there's a `B` subobject and an `A` subobject. The instance of `C`, including the `A` and `B` subobjects, is the "complete object."
2321

24-
Using run-time type information, it is possible to check whether a pointer actually points to a complete object and can be safely cast to point to another object in its hierarchy. The [dynamic_cast](../cpp/dynamic-cast-operator.md) operator can be used to make these types of casts. It also performs the run-time check necessary to make the operation safe.
22+
Because a derived class completely contains the definitions of all the base classes from which it's derived, it's safe to cast a pointer to any of its base classes (also called an upcast). Given a pointer to a base class, it may be safe to cast the pointer to an instance of a derived class (also called a downcast).
2523

26-
For conversion of nonpolymorphic types, you can use the [static_cast](../cpp/static-cast-operator.md) operator (this topic explains the difference between static and dynamic casting conversions, and when it is appropriate to use each).
24+
Using run-time type information, it's possible to check whether a pointer actually points to a complete object and can be safely cast to point to another object in its hierarchy. The [dynamic_cast](../cpp/dynamic-cast-operator.md) operator performs a run-time check to ensure that the operation is safe. It's better to design your class hierarchy so that you can use virtual functions to avoid the need for downcasting. However, if you must downcast, use `dynamic_cast` to ensure that the operation is safe.
2725

28-
This section covers the following topics:
26+
For conversion of nonpolymorphic types, you can use the [static_cast](../cpp/static-cast-operator.md) operator (this topic explains the difference between static and dynamic casting conversions, and when it's appropriate to use each).
27+
28+
The following example demonstrates the use of `dynamic_cast` and `static_cast`:
29+
30+
```cpp
31+
#include <iostream>
32+
33+
class Base {
34+
public:
35+
virtual void print() { std::cout << "Base\n"; }
36+
};
37+
38+
class Derived1 : public Base {
39+
public:
40+
void print() override { std::cout << "Derived1\n"; }
41+
};
42+
43+
class Derived2 : public Base {
44+
public:
45+
void print() override { std::cout << "Derived2\n"; }
46+
};
2947

30-
- [Casting operators](../cpp/casting-operators.md)
48+
class MostDerived : public Derived1, public Derived2 {
49+
public:
50+
void print() override { std::cout << "MostDerived\n"; }
51+
};
52+
53+
int main() {
54+
MostDerived md;
55+
Base* b1 = static_cast<Derived1*>(&md); // Upcast to Derived1 is safe
56+
Base* b2 = static_cast<Derived2*>(&md); // Upcast to Derived2 is safe
57+
58+
// Downcast to MostDerived is ambiguous and unsafe
59+
// MostDerived* md1 = static_cast<MostDerived*>(b1); // This won't compile
60+
// MostDerived* md2 = static_cast<MostDerived*>(b2); // This won't compile
61+
62+
// Correct way to downcast in this situation
63+
MostDerived* md1 = dynamic_cast<MostDerived*>(b1); // This is safe
64+
MostDerived* md2 = dynamic_cast<MostDerived*>(b2); // This is safe
65+
66+
md1->print(); // Prints "MostDerived"
67+
md2->print(); // Prints "MostDerived"
68+
69+
return 0;
70+
}
71+
```
72+
73+
This section covers the following topics:
3174
75+
- [Casting operators](../cpp/casting-operators.md)\
3276
- [Run-time type information](../cpp/run-time-type-information.md)
3377
3478
## See also

docs/cpp/data-type-ranges.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,25 @@ description: "Learn more about: Data Type Ranges"
33
title: "Data Type Ranges"
44
ms.date: "05/28/2020"
55
helpviewer_keywords: ["float keyword [C++]", "char keyword [C++]", "unsigned long", "__wchar_t keyword [C++]", "unsigned short int [C++]", "enum keyword [C++]", "unsigned char keyword [C++]", "integer data type [C++], data type ranges", "int data type", "data types [C++], ranges", "unsigned int [C++]", "short data type", "short int data", "signed types [C++], data type ranges", "long long keyword [C++]", "long double keyword [C++]", "double data type [C++], data type ranges", "signed short int [C++]", "unsigned short", "sized integer types", "signed int [C++]", "signed long int [C++]", "signed char keyword [C++]", "wchar_t keyword [C++]", "long keyword [C++]", "ranges [C++]", "unsigned types [C++], data type ranges", "floating-point numbers [C++]", "data type ranges", "ranges [C++], data types", "long int keyword [C++]", "unsigned long int [C++]"]
6-
ms.assetid: 3691ceca-05fb-4b82-b1ae-5c4618cda91a
76
---
87
# Data Type Ranges
98

109
The Microsoft C++ 32-bit and 64-bit compilers recognize the types in the table later in this article.
1110

12-
- **`int`** (**`unsigned int`**)
11+
```cpp
12+
- int (unsigned int)
13+
- __int8 (unsigned __int8)
14+
- __int16 (unsigned __int16)
15+
- __int32 (unsigned __int32)
16+
- __int64 (unsigned __int64)
17+
- short (unsigned short)
18+
- long (unsigned long)
19+
- long long (unsigned long long)
20+
```
1321
14-
- **`__int8`** (**`unsigned __int8`**)
22+
If its name begins with two underscores (`__`), the data type is nonstandard.
1523
16-
- **`__int16`** (**`unsigned __int16`**)
17-
18-
- **`__int32`** (**`unsigned __int32`**)
19-
20-
- **`__int64`** (**`unsigned __int64`**)
21-
22-
- **`short`** (**`unsigned short`**)
23-
24-
- **`long`** (**`unsigned long`**)
25-
26-
- **`long long`** (**`unsigned long long`**)
27-
28-
If its name begins with two underscores (`__`), a data type is non-standard.
29-
30-
The ranges that are specified in the following table are inclusive-inclusive.
24+
The ranges specified in the following table are inclusive-inclusive.
3125
3226
|Type Name|Bytes|Other Names|Range of Values|
3327
|---------------|-----------|-----------------|---------------------|
@@ -52,16 +46,16 @@ The ranges that are specified in the following table are inclusive-inclusive.
5246
|**`long long`**|8|none (but equivalent to **`__int64`**)|-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807|
5347
|**`unsigned long long`**|8|none (but equivalent to **`unsigned __int64`**)|0 to 18,446,744,073,709,551,615|
5448
|**`enum`**|varies|none| |
55-
|**`float`**|4|none|3.4E +/- 38 (7 digits)|
56-
|**`double`**|8|none|1.7E +/- 308 (15 digits)|
49+
|**`float`**|4|none|3.4E +/- 38 (seven digits)|
50+
|**`double`**|8|none|1.7E +/- 308 (fifteen digits)|
5751
|**`long double`**|same as **`double`**|none|Same as **`double`**|
5852
|**`wchar_t`**|2|**`__wchar_t`**|0 to 65,535|
5953
60-
Depending on how it's used, a variable of **`__wchar_t`** designates either a wide-character type or multibyte-character type. Use the `L` prefix before a character or string constant to designate the wide-character-type constant.
54+
A variable of **`__wchar_t`** designates either a wide-character type or multibyte-character type. Use the `L` prefix before a character or string constant to designate the wide-character-type constant.
6155
6256
**`signed`** and **`unsigned`** are modifiers that you can use with any integral type except **`bool`**. Note that **`char`**, **`signed char`**, and **`unsigned char`** are three distinct types for the purposes of mechanisms like overloading and templates.
6357
64-
The **`int`** and **`unsigned int`** types have a size of four bytes. However, portable code should not depend on the size of **`int`** because the language standard allows this to be implementation-specific.
58+
The **`int`** and **`unsigned int`** types have a size of 4 bytes. However, portable code shouldn't depend on the size of **`int`** because the language standard allows this to be implementation-specific.
6559
6660
C/C++ in Visual Studio also supports sized integer types. For more information, see [`__int8, __int16, __int32, __int64`](../cpp/int8-int16-int32-int64.md) and [Integer Limits](../cpp/integer-limits.md).
6761
@@ -71,5 +65,5 @@ The range of enumerated types varies depending on the language context and speci
7165
7266
## See also
7367
74-
[Keywords](../cpp/keywords-cpp.md)<br/>
68+
[Keywords](../cpp/keywords-cpp.md)\
7569
[Built-in types](../cpp/fundamental-types-cpp.md)
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
---
2-
description: "Learn more about: Compiler Error C2055"
3-
title: "Compiler Error C2055"
4-
ms.date: "11/04/2016"
2+
description: "Learn more about: Microsoft Visual C++ compiler error C2055"
3+
title: "Compiler error C2055"
4+
ms.date: 06/10/2024
55
f1_keywords: ["C2055"]
66
helpviewer_keywords: ["C2055"]
7-
ms.assetid: 6cec79cc-6bec-443f-9897-fbf5452718c7
87
---
9-
# Compiler Error C2055
8+
# Compiler error C2055
109

11-
expected formal parameter list, not a type list
10+
> expected formal parameter list, not a type list
1211
13-
A function definition contains a parameter type list instead of a formal parameter list. ANSI C requires formal parameters to be named unless they are void or an ellipsis (`...`).
12+
A function definition contains a parameter type list instead of a formal parameter list. ANSI C requires formal parameters to be named unless they're `void` or an ellipsis (`...`).
1413

15-
The following sample generates C2055:
14+
An example of a named formal parameter is the `int i` in `void func(int i)`.\
15+
A parameter type list is a list of types, for example, `int, char`.
16+
17+
The following code generates error `C2055`:
1618

1719
```c
1820
// C2055.c
1921
// compile with: /c
2022
void func(int, char) {} // C2055
21-
void func (int i, char c) {} // OK
23+
void func (int i, char c) {} // OK
2224
```

0 commit comments

Comments
 (0)