Skip to content

Repo sync for protected CLA branch #3119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 5, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Base filename (without extension). You can pass **NULL** for this parameter if y
The size of the *fname* buffer in single-byte or wide characters. If *fname* is **NULL**, this value must be 0.

*ext*<br/>
Filename extension, including leading period (**.**).You can pass **NULL** for this parameter if you do not need the filename extension.
Filename extension, including leading period (**.**). You can pass **NULL** for this parameter if you do not need the filename extension.

*extNumberOfElements*<br/>
The size of *ext* buffer in single-byte or wide characters. If *ext* is **NULL**, this value must be 0.
Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6290.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ms.assetid: 96a1acc4-724b-4b56-b091-661ddcc03884

This warning indicates possible confusion in the use of an operator or an operator precedence.

The `!` operator yields a Boolean result, and it has higher precedence than the `&`.The bitwise-and (&) operator takes two arithmetic arguments. Therefore, one of the following errors has been detected:
The `!` operator yields a Boolean result, and it has higher precedence than the `&`. The bitwise-and (&) operator takes two arithmetic arguments. Therefore, one of the following errors has been detected:

- The expression is mis-parenthesised:

Expand Down
2 changes: 1 addition & 1 deletion docs/cppcx/partial-classes-c-cx.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following code fragment demonstrates accessibility. In the first partial cla

A partial definition of a class such as `MyClass` is only a declaration of MyClass. That is, it only introduces the name `MyClass`. `MyClass` can't be used in a way that requires a class definition, for example, knowing the size of `MyClass` or using a base or member of `MyClass`. `MyClass` is considered to be defined only when the compiler encounters a non-partial definition of `MyClass`.

The following example demonstrates the declaration behavior of a partial class. After declaration #1, `MyClass` can be used as if it were written as the forward declaration, `ref class MyClass;`. Declaration #2 is equivalent to declaration #1.Declaration #3 is valid because it's a forward declaration to a class. But declaration #4 is invalid because
The following example demonstrates the declaration behavior of a partial class. After declaration #1, `MyClass` can be used as if it were written as the forward declaration, `ref class MyClass;`. Declaration #2 is equivalent to declaration #1. Declaration #3 is valid because it's a forward declaration to a class. But declaration #4 is invalid because

`MyClass` is not fully defined.

Expand Down
7 changes: 4 additions & 3 deletions docs/error-messages/compiler-errors-1/compiler-error-c2139.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
---
description: "Learn more about: Compiler Error C2139"
title: "Compiler Error C2139"
ms.date: "11/04/2016"
ms.date: 05/03/2021
f1_keywords: ["C2139"]
helpviewer_keywords: ["C2139"]
ms.assetid: 31e047c0-5bf9-46c2-b6de-b627ea6a5768
---
# Compiler Error C2139

'type' : an undefined class is not allowed as an argument to compiler intrinsic type trait 'trait'
> '*type*' : an undefined class is not allowed as an argument to compiler intrinsic type trait '*trait*'
An invalid argument was passed to a type trait.

## Remarks

For more information, see [Compiler Support for Type Traits](../../extensions/compiler-support-for-type-traits-cpp-component-extensions.md).

## Example
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2201.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
---
description: "Learn more about: Compiler Error C2201"
title: "Compiler Error C2201"
ms.date: "11/04/2016"
ms.date: 05/03/2021
f1_keywords: ["C2201"]
helpviewer_keywords: ["C2201"]
ms.assetid: ed927659-6e9c-447d-9963-19969ae1e957
---
# Compiler Error C2201

'identifier' : must have external linkage in order to be exported/imported
> '*identifier*' : must have external linkage in order to be exported/imported
The exported identifier is **`static`**.

The following sample generates C2286:
## Example

The following sample generates C2286, and shows how to fix it:

```cpp
// C2201.cpp
Expand Down
20 changes: 9 additions & 11 deletions docs/error-messages/compiler-errors-2/compiler-error-c2668.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
description: "Learn more about: Compiler Error C2668"
title: "Compiler Error C2668"
ms.date: "03/28/2017"
ms.date: 05/03/2021
f1_keywords: ["C2668"]
helpviewer_keywords: ["C2668"]
ms.assetid: 041e9627-1c76-420e-a653-cfc83f933bd3
---
# Compiler Error C2668

'function' : ambiguous call to overloaded function
> 'function' : ambiguous call to overloaded function
The specified overloaded function call could not be resolved. You may want to explicitly cast one or more of the actual parameters.
The specified overloaded function call couldn't be resolved. You may want to explicitly cast one or more of the actual parameters.

You can also get this error through template use. If, in the same class, you have a regular member function and a templated member function with the same signature, the templated one must come first. This is a limitation of the current implementation of Visual C++.
You can also get this error through template use. If, in the same class, you have a regular member function and a templated member function with the same signature, the templated one must come first. This limitation remains in the current implementation of Visual C++.

## Examples

Expand All @@ -34,7 +34,7 @@ int main() {
}
```
Another way to resolve this error is with a [using declaration](../../cpp/using-declaration.md):
Another way to resolve this error is with a [`using` declaration](../../cpp/using-declaration.md):
```cpp
// C2668b.cpp
Expand Down Expand Up @@ -75,9 +75,7 @@ class MyTestCase : public AppTestCase {
};
```

This error can also be generated as a result of compiler conformance work that was done for Visual Studio .NET 2003: ambiguous conversion on cast of constant 0.

Conversion on a cast using constant 0 is ambiguous since int requires a conversion both to long and to void*. To resolve this error, cast 0 to the exact type of the function parameter it is being used for so that no conversions need to take place (this code will be valid in the Visual Studio .NET 2003 and Visual Studio .NET versions of Visual C++).
Conversion on a cast using constant 0 is ambiguous since **`int`** requires a conversion both to **`long`** and to `void*`. To resolve this error, cast 0 to the exact type of the function parameter it's being used for. Then no conversions need to take place.

```cpp
// C2668c.cpp
Expand All @@ -97,7 +95,7 @@ int main() {
}
```
This error can occur because the CRT now has float and double forms of all math functions.
This error can occur because the CRT now has **`float`** and **`double`** forms of all math functions.
```cpp
// C2668d.cpp
Expand All @@ -110,7 +108,7 @@ int main() {
}
```

This error can occur because the pow(int, int) was removed from math.h in the CRT.
This error can occur because the `pow(int, int)` was removed from *`math.h`* in the CRT.

```cpp
// C2668e.cpp
Expand All @@ -121,7 +119,7 @@ int main() {
}
```

This code succeeds in Visual Studio 2015 but fails in Visual Studio 2017 and later with C2668. In Visual Studio 2015, the compiler erroneously treated copy-list-initialization in the same way as regular copy-initialization; it considered only converting constructors for overload resolution.
This code succeeds in Visual Studio 2015 but fails in Visual Studio 2017 and later with C2668. In Visual Studio 2015, the compiler erroneously treated copy-list-initialization in the same way as regular copy-initialization. It considered only converting constructors for overload resolution.

```cpp
struct A {
Expand Down
19 changes: 19 additions & 0 deletions docs/error-messages/compiler-errors-2/compiler-error-c7536.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
description: "Learn about the causes of Compiler error C7536 and how to fix it."
title: "Compiler Error C7536"
ms.date: 05/03/2021
f1_keywords: ["C7536"]
helpviewer_keywords: ["C7536"]
---
# Compiler Error C7536

> ifc failed integrity checks. Expected SHA2: '*hash-value*'
The compiler raises C7536 whenever the *`.ifc`* file has been tampered with. The header of the module interface contains an SHA2 hash of the contents below it. On import, the *`.ifc`* file is hashed, then checked against the hash provided in the header. If these don't match, error C7536 is raised:

```Output
error C7536: ifc failed integrity checks.
Expected SHA2: '66d5c8154df0c71d4cab7665bab4a125c7ce5cb9a401a4d8b461b706ddd771c6'
```

This error is new in Visual Studio 2017 version 15.9. It's only generated when creating or consuming modules, specified by the `/experimental:module` compiler option.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description: "Learn more about: Compiler errors C7500 through C7999"
title: "Compiler errors C7500 through C7999"
ms.date: 04/18/2021
f1_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7536", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7553", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
helpviewer_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7536", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7553", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
f1_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7553", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
helpviewer_keywords: ["C7500", "C7501", "C7502", "C7503", "C7504", "C7505", "C7506", "C7507", "C7508", "C7509", "C7511", "C7512", "C7513", "C7514", "C7515", "C7516", "C7517", "C7518", "C7519", "C7520", "C7521", "C7522", "C7523", "C7524", "C7525", "C7526", "C7527", "C7528", "C7529", "C7530", "C7531", "C7532", "C7533", "C7534", "C7535", "C7537", "C7538", "C7539", "C7540", "C7541", "C7542", "C7543", "C7544", "C7545", "C7546", "C7547", "C7548", "C7549", "C7550", "C7551", "C7552", "C7553", "C7554", "C7555", "C7556", "C7557", "C7558", "C7559", "C7560", "C7561", "C7562", "C7563", "C7564", "C7565", "C7566", "C7567", "C7568", "C7569", "C7570", "C7571", "C7572", "C7573", "C7574", "C7575", "C7576", "C7577", "C7578", "C7579", "C7580", "C7581", "C7582", "C7583", "C7584", "C7585", "C7586", "C7587", "C7588", "C7589", "C7590", "C7591", "C7592", "C7593", "C7594", "C7595", "C7596", "C7597", "C7599", "C7600", "C7601", "C7602", "C7603", "C7604", "C7605", "C7606", "C7607", "C7608", "C7609", "C7610", "C7611", "C7612", "C7613", "C7614", "C7615", "C7616", "C7617", "C7618", "C7619", "C7620", "C7621", "C7622", "C7623", "C7624", "C7625", "C7627", "C7628", "C7629", "C7630", "C7631", "C7632", "C7633", "C7634", "C7635", "C7636", "C7637", "C7638", "C7639", "C7640", "C7641", "C7642", "C7643", "C7644", "C7645", "C7646", "C7647", "C7648", "C7649", "C7650", "C7651", "C7652", "C7653", "C7654", "C7655", "C7656", "C7657", "C7658", "C7659", "C7660", "C7661", "C7662", "C7700", "C7701", "C7702", "C7703", "C7704"]
---
# Compiler errors C7500 through C7999

Expand Down Expand Up @@ -51,7 +51,7 @@ The articles in this section of the documentation explain a subset of the error
| Compiler error C7533 | '%$S': template arguments not allowed in this context |
| Compiler error C7534 | syntax error: '%$L': expected class definition to end with '}' |
| Compiler error C7535 | '%$S': delegating constructor calls itself |
| Compiler error C7536 | ifc failed integrity checks. Expected SHA2: '%s' |
| [Compiler error C7536](compiler-error-c7536.md) | ifc failed integrity checks. Expected SHA2: '*hash-value*' |
| Compiler error C7537 | failed to properly compute SHA2 hash: '%s' |
| Compiler error C7538 | '%$I' is not a variable template |
| Compiler error C7539 | '%1$I': a class with user-declared constructors cannot have a member with the same name as the class |
Expand Down
34 changes: 34 additions & 0 deletions docs/error-messages/compiler-warnings/c4597.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: "Learn more about: Compiler Warning (error) C4597"
title: "Compiler Warning (error) C4597"
ms.date: 05/03/2021
f1_keywords: ["C4597"]
helpviewer_keywords: ["C4597"]
---
# Compiler Warning (error) C4597

> undefined behavior: `offsetof` applied to a member of a virtual base
Using `offsetof(T, m)` where *`m`* refers to a static data member or a member function results in C4597.

## Remarks

This warning is new in Visual Studio 2017 version 15.3. It's reported as an error by default. For information on how to disable warnings by compiler version, see [Compiler warnings by compiler version](compiler-warnings-by-compiler-version.md).

## Example

The following code produces error C4597:

```cpp
#include <cstddef>

struct A {
int ten() { return 10; }
static constexpr int two = 2;
};

constexpr auto off = offsetof(A, ten); // C4597: undefined behavior: offsetof applied to member function 'A::ten'
constexpr auto off2 = offsetof(A, two); // C4597: undefined behavior: offsetof applied to static data member 'A::two'
```
This code is ill-formed and could potentially cause a crash at runtime. To fix the error, change the code: don't invoke `offsetof` on member functions or static data members. It's non-portable code that's disallowed by the C++ standard.
30 changes: 30 additions & 0 deletions docs/error-messages/compiler-warnings/c4768.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
description: "Learn more about: Compiler Warning (level 3) C4768"
title: "Compiler Warning (level 3) C4768"
ms.date: 05/03/2021
f1_keywords: ["C4768"]
helpviewer_keywords: ["C4768"]
---
# Compiler Warning (level 3) C4768

> `__declspec` attributes before linkage specification are ignored
The compiler warns if `__declspec(...)` is applied before the `extern "C"` linkage specification. Previously, the compiler would ignore the attribute, which could have runtime implications.

## Remarks

This warning is new in Visual Studio 2017 version 15.3, which left it off by default. It's enabled by default as a level 3 warning starting in Visual Studio 2017 version 15.5. For information on how to disable warnings by compiler version, see [Compiler warnings by compiler version](compiler-warnings-by-compiler-version.md).

## Example

The following code produces warning C4768:

```cpp
__declspec(noinline) extern "C" HRESULT __stdcall // C4768: __declspec attributes before linkage specification are ignored
```
To fix the warning, put `extern "C"` first:
```cpp
extern "C" __declspec(noinline) HRESULT __stdcall
```
31 changes: 31 additions & 0 deletions docs/error-messages/compiler-warnings/c4841.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
description: "Learn more about: Compiler Warning (level 4) C4841"
title: "Compiler Warning (level 4) C4841"
ms.date: 05/03/2021
f1_keywords: ["C4841"]
helpviewer_keywords: ["C4841"]
---
# Compiler Warning (level 4) C4841

> non-standard extension used: compound member designator used in `offsetof`
## Remarks

If you use `offsetof(T, m)`, where *`m`* is a compound member designator, the compiler generates a warning when you compile with the **`/Wall`** option.

This warning is new in Visual Studio 2017 version 15.3, and is off by default. Use [`/Wall`](../../build/reference/compiler-option-warning-level.md) to enable all warnings that are off by default, or **`/w14841`** to enable C4841 as a level 1 warning. For more information, see [Compiler warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md). For information on how to disable warnings by compiler version, see [Compiler warnings by compiler version](compiler-warnings-by-compiler-version.md).

## Example

The following code is ill-formed and could potentially cause a crash at runtime:

```cpp
struct A {
int arr[10];
};

// warning C4841: non-standard extension used: compound member designator in offsetof
constexpr auto off = offsetof(A, arr[2]);
```
To fix the issue, change the code to not use `offsetof` with a compound member designator.
Loading