Skip to content

Commit ac3c8fb

Browse files
authored
Merge pull request #5716 from Rageking8/structure-warning-references-in-range-c4271-c4310
Structure warning references in range [C4271, C4310]
2 parents d8d010c + aee3048 commit ac3c8fb

28 files changed

+178
-109
lines changed

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4272.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4272"
32
title: "Compiler Warning (level 1) C4272"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4272"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4272"]
66
helpviewer_keywords: ["C4272"]
7-
ms.assetid: 0d6c1de4-2eef-42c4-b861-c221f8b495ef
87
---
98
# Compiler Warning (level 1) C4272
109

11-
'function' : is marked __declspec(dllimport); must specify native calling convention when importing a function.
10+
> 'function' : is marked __declspec(dllimport); must specify native calling convention when importing a function.
11+
12+
## Remarks
1213

1314
It is an error to export a function marked with the [__clrcall](../../cpp/clrcall.md) calling convention, and the compiler issues this warning if you attempt to import a function marked `__clrcall`.
1415

15-
The following sample generates C4272:
16+
## Example
17+
18+
The following example generates C4272:
1619

1720
```cpp
1821
// C4272.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4273.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4273"
32
title: "Compiler Warning (level 1) C4273"
3+
description: "Learn more about: Compiler Warning (level 1) C4273"
44
ms.date: 05/23/2022
55
f1_keywords: ["C4273"]
66
helpviewer_keywords: ["C4273"]
7-
ms.assetid: cc18611d-9454-40a4-ad73-69823d5888fb
87
---
98
# Compiler Warning (level 1) C4273
109

1110
> '*function*' : inconsistent DLL linkage
1211
12+
## Remarks
13+
1314
Two definitions in a file differ in their use of [`dllimport`](../../cpp/dllexport-dllimport.md).
1415

1516
## Examples
1617

17-
The following sample generates C4273, and shows how to fix it.
18+
The following example generates C4273, and shows how to fix it.
1819

1920
```cpp
2021
// C4273.cpp
@@ -23,7 +24,7 @@ char __declspec(dllimport) c;
2324
char c; // C4273, delete this line or the line above to resolve
2425
```
2526
26-
The following sample generates C4273. To fix it, delete the redeclaration of `printf_s`.
27+
The following example generates C4273. To fix it, delete the redeclaration of `printf_s`.
2728
2829
```cpp
2930
// C4273_b.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4274.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4274"
32
title: "Compiler Warning (level 1) C4274"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4274"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4274"]
66
helpviewer_keywords: ["C4274"]
7-
ms.assetid: 5a948680-7ed1-469f-978d-ae99d154e161
87
---
98
# Compiler Warning (level 1) C4274
109

11-
\#ident ignored; see documentation for #pragma comment(exestr, 'string')
10+
> #ident ignored; see documentation for #pragma comment(exestr, 'string')
11+
12+
## Remarks
1213

1314
The `#ident` directive, which inserts a user-specified string in the object or executable file, is deprecated. Consequently, the compiler ignores the directive.
1415

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4276"
32
title: "Compiler Warning (level 1) C4276"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4276"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4276"]
66
helpviewer_keywords: ["C4276"]
7-
ms.assetid: 9d738c2d-29e5-408a-b9ff-be1a850b2238
87
---
98
# Compiler Warning (level 1) C4276
109

11-
'function' : no prototype provided; assumed no parameters
10+
> 'function' : no prototype provided; assumed no parameters
11+
12+
## Remarks
1213

1314
When you take the address of a function with the [__stdcall](../../cpp/stdcall.md) calling convention, you must give a prototype so the compiler can create the function's decorated name. Since *function* has no prototype, the compiler, when creating the decorated name, assumes the function has no parameters.

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4286.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4286"
32
title: "Compiler Warning (level 1) C4286"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4286"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4286"]
66
helpviewer_keywords: ["C4286"]
7-
ms.assetid: 93eadd6c-6f36-413b-ba91-c9aa2314685a
87
---
98
# Compiler Warning (level 1) C4286
109

11-
'type1' : is caught by base class ('type2') on line number
10+
> 'type1' : is caught by base class ('type2') on line number
11+
12+
## Remarks
1213

1314
The specified exception type is handled by a previous handler. The type for the second catch is derived from the type of the first. Exceptions for a base class catch exceptions for a derived class.
1415

1516
## Example
1617

18+
The following example generates C4286:
19+
1720
```cpp
1821
//C4286.cpp
1922
// compile with: /W1

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4288.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4288"
32
title: "Compiler Warning (level 1) C4288"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4288"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4288"]
66
helpviewer_keywords: ["C4288"]
7-
ms.assetid: 6aaeb139-90cd-457a-9d37-65687042736f
87
---
98
# Compiler Warning (level 1) C4288
109

1110
> nonstandard extension used : 'var' : loop control variable declared in the for-loop is used outside the for-loop scope; it conflicts with the declaration in the outer scope
1211
12+
## Remarks
13+
1314
When compiling with [`/Ze`](../../build/reference/za-ze-disable-language-extensions.md) and **/Zc:forscope-**, a variable declared in a **`for`** loop was used after the [for](../../cpp/for-statement-cpp.md)-loop scope. A Microsoft extension to the C++ language allows this variable to remain in scope, and C4288 reminds you that the first declaration of the variable is not used.
1415

1516
See [`/Zc:forScope`](../../build/reference/zc-forscope-force-conformance-in-for-loop-scope.md) for information about how to specify the Microsoft extension in **`for`** loops with /Ze.
1617

17-
The following sample generates C4288:
18+
## Example
19+
20+
The following example generates C4288:
1821

1922
```cpp
2023
// C4288.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4291.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4291"
32
title: "Compiler Warning (level 1) C4291"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4291"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4291"]
66
helpviewer_keywords: ["C4291"]
7-
ms.assetid: c2b95dea-38f2-4609-9104-707c30798da4
87
---
98
# Compiler Warning (level 1) C4291
109

11-
'declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception
10+
> 'declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception
11+
12+
## Remarks
1213

1314
A placement [new](../../cpp/new-operator-cpp.md) is used for which there is no placement [delete](../../cpp/delete-operator-cpp.md).
1415

1516
When memory is allocated for an object with operator **`new`**, the object's constructor is called. If the constructor throws an exception, any memory that was allocated for the object should be deallocated. This cannot take place unless an operator **`delete`** function exists that matches the operator **`new`**.
1617

1718
If you use the operator **`new`** without any extra arguments and compile with [/GX](../../build/reference/gx-enable-exception-handling.md), [/EHs](../../build/reference/eh-exception-handling-model.md), or /EHa options to enable exception handling, the compiler will generate code to call operator **`delete`** if the constructor throws an exception.
1819

19-
If you use the placement form of the **`new`** operator (the form with arguments in addition to the size of the allocation) and the object's constructor throws an exception, the compiler will still generate code to call operator **`delete`**; but it will only do so if a placement form of operator **`delete`** exists matching the placement form of the operator **`new`** that allocated the memory. For example:
20+
If you use the placement form of the **`new`** operator (the form with arguments in addition to the size of the allocation) and the object's constructor throws an exception, the compiler will still generate code to call operator **`delete`**; but it will only do so if a placement form of operator **`delete`** exists matching the placement form of the operator **`new`** that allocated the memory.
21+
22+
## Example
23+
24+
For example:
2025

2126
```cpp
2227
// C4291.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4293.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ description: "Describes the causes of MSVC compiler warning C4293, and shows how
44
ms.date: 07/15/2020
55
f1_keywords: ["C4293"]
66
helpviewer_keywords: ["C4293"]
7-
ms.assetid: babecd96-eb51-41a5-9835-462c7a46dbad
87
---
98
# Compiler Warning (level 1) C4293
109

1110
> '*operator*' : shift count negative or too big, undefined behavior
1211
13-
If a shift count is negative or too large, the behavior of the resulting image is undefined.
14-
1512
## Remarks
1613

14+
If a shift count is negative or too large, the behavior of the resulting image is undefined.
15+
1716
To resolve this issue, you can use a cast on the first operand to expand it to the size of the result type.
1817

1918
## Example
2019

21-
The following sample generates C4293, and shows ways to fix it:
20+
The following example generates C4293, and shows ways to fix it:
2221

2322
```cpp
2423
// C4293.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4297.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4297"
32
title: "Compiler Warning (level 1) C4297"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4297"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4297"]
66
helpviewer_keywords: ["C4297"]
7-
ms.assetid: ba92fcdc-9f70-4f60-abe6-281f9582ca59
87
---
98
# Compiler Warning (level 1) C4297
109

11-
'function' : function assumed not to throw an exception but does
10+
> 'function' : function assumed not to throw an exception but does
11+
12+
## Remarks
1213

1314
A function declaration contains a (possibly implicit) **`noexcept`** specifier, an empty **`throw`** exception specifier, or a [__declspec(nothrow)](../../cpp/nothrow-cpp.md) attribute, and the definition contains one or more [throw](../../cpp/try-throw-and-catch-statements-cpp.md) statements. To resolve C4297, do not attempt to throw exceptions in functions that are declared `__declspec(nothrow)`, `noexcept(true)` or `throw()`. Alternatively, remove the **`noexcept`**, `throw()`, or `__declspec(nothrow)` specification.
1415

@@ -18,7 +19,9 @@ For more information on exception specifications, see [Exception Specifications
1819

1920
This warning is also generated for __declspec([dllexport](../../cpp/dllexport-dllimport.md)) functions marked extern "C", even if they are C++ functions.
2021

21-
The following sample generates C4297:
22+
## Example
23+
24+
The following example generates C4297:
2225

2326
```cpp
2427
// C4297.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4305.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1 and level 2 and level 4) C4305"
32
title: "Compiler Warning (level 1 and level 2 and level 4) C4305"
4-
ms.date: "01/17/2018"
3+
description: "Learn more about: Compiler Warning (level 1 and level 2 and level 4) C4305"
4+
ms.date: 01/17/2018
55
f1_keywords: ["C4305"]
66
helpviewer_keywords: ["C4305"]
77
---
@@ -15,7 +15,7 @@ This warning is issued when a value is converted to a smaller type in an initial
1515

1616
## Example
1717

18-
This sample shows two ways you might see this warning:
18+
This example shows two ways you might see this warning:
1919

2020
```cpp
2121
// C4305.cpp

0 commit comments

Comments
 (0)