Skip to content

Commit 14e0b60

Browse files
authored
Add "Remarks" and "Example" headings for warning references in range [C4831, C4940]
1 parent ebfa74b commit 14e0b60

26 files changed

+79
-1
lines changed

docs/error-messages/compiler-warnings/compiler-warning-c4867.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: 8a257d70-c3a7-462d-b285-e57c952a8bf7
1010

1111
> 'function': function call missing argument list; use 'call' to create a pointer to member
1212
13+
## Remarks
14+
1315
A pointer to member function was initialized incorrectly.
1416

1517
This warning can be generated as a result of compiler conformance work that was done for Visual Studio 2005: enhanced pointer-to-member conformance. Code that compiled prior to Visual Studio 2005 will now generate C4867.

docs/error-messages/compiler-warnings/compiler-warning-c4868.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: fc6aa7e5-34dd-4ec2-88bd-16e430361dc7
1010

1111
> '_file_(*line_number*)' compiler may not enforce left-to-right evaluation order in braced initializer list
1212
13+
## Remarks
14+
1315
The elements of a braced initializer list are to be evaluated in left-to-right order. There are two cases in which the compiler is unable to guarantee this order: the first is when some of the elements are objects passed by value; the second is when compiling with `/clr` and some of the elements are fields of objects or are array elements. When the compiler can't guarantee left-to-right evaluation it emits warning C4868.
1416

1517
This warning can be generated as a result of compiler conformance work that was done for Visual Studio 2015 Update 2. Code that compiled prior to Visual Studio 2015 Update 2 can now generate C4868.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: d2e44c62-7b0e-4a45-943d-97903e27ed9d
1010

1111
> 'variable' : the initializer for exported data will not be run until managed code is first executed in the host assembly
1212
13+
## Remarks
14+
1315
When accessing data between managed components, it is recommended that you not use native C++ import and export mechanisms. Instead, declare your data members inside a managed type and reference the metadata with `#using` in the client. For more information, see [#using Directive](../../preprocessor/hash-using-directive-cpp.md).
1416

1517
## Examples

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ ms.assetid: fea07924-5feb-4ed4-99b5-1a8c41d28db6
1010

1111
> conversion from 'type_1' to 'type_2' requires a narrowing conversion
1212
13+
## Remarks
14+
1315
An implicit narrowing conversion was found when using aggregate or list initialization.
1416

1517
The C language allows implicit narrowing conversions in assignments and initialization, and C++ follows suit, even though unexpected narrowing is a cause of many code errors. To make code safer, the C++ standard requires a diagnostic message when a narrowing conversion occurs in an initialization list. In Visual C++, the diagnostic is [Compiler Error C2397](../../error-messages/compiler-errors-1/compiler-error-c2397.md) when using the uniform initialization syntax supported beginning in Visual Studio 2015. The compiler generates warning C4838 when using the list or aggregate initialization syntax supported by Visual Studio 2013.
1618

1719
A narrowing conversion can be okay when you know the possible range of converted values can fit in the target. In this case, you know more than the compiler does. If you make a narrowing conversion intentionally, make your intentions explicit by using a static cast. Otherwise, this warning message almost always indicates that you have a bug in your code. You can fix it by making sure the objects you initialize have types that are large enough to handle the inputs.
1820

21+
## Example
22+
1923
The following sample generates C4838 and shows one way to fix it:
2024

2125
```cpp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ ms.assetid: 826997ec-0803-4794-ad35-bb463f679658
1010

1111
> intermediate language mismatch between 'tool1' version 'version1' and 'tool2' version 'version2'
1212
13+
## Remarks
14+
1315
The intermediate language used in *tool1* and *tool2* did not match. Check that the most current version of each tool has been installed.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: 40240bf4-b14e-4c22-aeb2-52f2851532f6
1010

1111
> wide string literal cast to 'LPSTR'
1212
13+
## Remarks
14+
1315
The compiler detected an unsafe cast. The cast did succeed, but you should use a conversion routine.
1416

1517
This warning is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) for more information.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: 05318e74-799b-412a-9dce-f02b8161d762
1010

1111
> string literal cast to 'LPWSTR'
1212
13+
## Remarks
14+
1315
The compiler detected an unsafe cast. The cast did succeed, but you should use a conversion routine.
1416

1517
This warning is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) for more information.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: 67963560-fbca-4ca7-93db-06beaf7055f0
1010

1111
> '\<identifier>' : '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
1212
13+
## Remarks
14+
1315
The explicit template instantiation named *\<identifier>* is modified by both the `__declspec(dllexport)` and **`extern`** keywords. However, these keywords are mutually exclusive. The `__declspec(dllexport)` keyword means instantiate the template class, while the **`extern`** keyword means do not automatically instantiate the template class.
1416

1517
## See also

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ ms.assetid: ba1f1a66-8c20-4792-9ac8-43e49f729ae2
1010

1111
> 'attribute': attribute has undefined behavior on a nested UDT
1212
13+
## Remarks
14+
1315
Attributes that apply to nested UDTs (user-defined type, which could be a typedef, union, or struct) may be ignored.
1416

17+
## Example
18+
1519
The following code shows how this warning would be generated:
1620

1721
```cpp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ms.assetid: c05e2610-4a5d-4f4b-a99b-c15fd7f1d5f1
1010

1111
> 'declarator' : a GUID can only be associated with a class, interface or namespace
1212
13+
## Remarks
14+
1315
A user-defined structure other than [class](../../cpp/class-cpp.md), [interface](../../cpp/interface.md), or [namespace](../../cpp/namespaces-cpp.md) cannot have a GUID.
1416

1517
This warning is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) for more information.

0 commit comments

Comments
 (0)