Skip to content

Commit b033f79

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#3198 from MicrosoftDocs/master637592892694290817
Repo sync for protected CLA branch
2 parents ea42c43 + cef73a0 commit b033f79

File tree

7 files changed

+448
-60
lines changed

7 files changed

+448
-60
lines changed

docs/code-quality/c6389.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: C6389
3+
description: "Describes the Microsoft C/C++ code analysis warning C6389, its causes, and how to address it."
4+
ms.date: 06/09/2021
5+
f1_keywords: ["C6389"]
6+
helpviewer_keywords: ["C6389"]
7+
---
8+
9+
# C6389: MARK_INTERNAL_OR_MISSING_COMMON_DECL
10+
11+
This check is intended to help reduce the visibility of certain symbols and to modularize the code. In multi-file C++ projects, each declaration should be either local to a C++ file (part of the anonymous namespace) or declared in a common header file that's included by multiple C++ files.
12+
13+
When this check flags a declaration, either it should be moved to an anonymous namespace or a forward declaration should be moved to a header file, depending on the scope of the symbol.
14+
15+
The rule is an experimental rule that must be explicitly enabled in a rule set file to work. For more information about rule sets, see [Use rule sets to group code analysis rules](/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules).
16+
17+
## Example
18+
19+
```cpp
20+
// A.h
21+
struct X;
22+
```
23+
24+
```cpp
25+
// A.cpp
26+
#include "A.h"
27+
28+
// Not flagged, declared in a header file.
29+
struct X { int x; };
30+
31+
struct Y { double y; }; // warning: Move 'Y' to anonymous namespace or put a forward declaration in a common header included in this file.
32+
33+
void f(); // warning: Move 'f' to anonymous namespace or put a forward declaration in a common header included in this file.
34+
```
35+
36+
One way to resolve these issues is to move `struct Y` into an anonymous namespace, and move the declaration of `f` into a header:
37+
38+
```cpp
39+
// A.h
40+
struct X;
41+
void f();
42+
```
43+
44+
```cpp
45+
// A.cpp
46+
#include "A.h"
47+
48+
// Not flagged, declared in a header file.
49+
struct X { int x; };
50+
51+
namespace {
52+
struct Y { double y; };
53+
} // anonymous namespace
54+
55+
// Not flagged, declared in a header file.
56+
void f();
57+
```

docs/code-quality/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@
462462
href: ../code-quality/c6387.md
463463
- name: C6388
464464
href: ../code-quality/c6388.md
465+
- name: C6389
466+
href: ../code-quality/c6389.md
465467
- name: C6400
466468
href: ../code-quality/c6400.md
467469
- name: C6401

docs/error-messages/compiler-errors-2/compiler-errors-c2700-through-c2799.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The articles in this section of the documentation explain a subset of the error
5353
|[Compiler error C2734](compiler-error-c2734.md)|'*identifier*': 'const' object must be initialized if not 'extern'|
5454
|[Compiler error C2735](compiler-error-c2735.md)|'*keyword*' keyword is not permitted in formal parameter type specifier|
5555
|[Compiler error C2736](compiler-error-c2736.md)|'*keyword*' keyword is not permitted in cast|
56-
|Compiler error C2737|'*identifier*': 'constexpr' object must be initialized|
56+
|Compiler error C2737|'*identifier*': `const`/`constexpr` object must be initialized|
5757
|[Compiler error C2738](compiler-error-c2738.md)|'operator *type*': is ambiguous or is not a member of '*class*'|
5858
|[Compiler error C2739](compiler-error-c2739.md)|'*number*': explicit managed/WinRT array dimensions must be between 1 and 32|
5959
|Compiler error C2740|value of operand '*number*' is out of range '*lower_bound* - *upper_bound*'|

docs/error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Compiler Warnings by compiler version"
33
description: "Table of Microsoft C/C++ compiler warnings by compiler version."
4-
ms.date: 06/07/2021
4+
ms.date: 06/11/2021
55
helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting warning options"]
66
---
77
# Compiler Warnings by compiler version
@@ -41,13 +41,23 @@ These versions of the compiler introduced new warnings:
4141
| Visual Studio 2019 version 16.8 | 19.28.29330.0 |
4242
| Visual Studio 2019 version 16.9 | 19.28.29500.0 |
4343
| Visual Studio 2019 version 16.10 | 19.28.30000.0 |
44+
| Visual Studio 2019 version 16.11 | 19.28.30100.0 |
4445

4546
You can specify only the major number, the major and minor numbers, or the major, minor, and build numbers to the **`/Wv`** option. The compiler reports all warnings that match versions that begin with the specified number. It suppresses all warnings for versions greater than the specified number. For example, **`/Wv:17`** reports warnings introduced in or before any version of Visual Studio 2012, and suppresses warnings introduced by any compiler from Visual Studio 2013 (version 18) or later. To suppress warnings introduced in Visual Studio 2015 update 2 and later, you can use **`/Wv:19.00.23506`**. Use **`/Wv:19.11`** to report the warnings introduced in any version of Visual Studio before Visual Studio 2017 version 15.5, but suppress warnings introduced in Visual Studio 2017 version 15.5 and later.
4647

4748
The following sections list the warnings introduced by each version of Visual C++ that you can suppress by using the **`/Wv`** compiler option. The **`/Wv`** option can't suppress warnings that aren't listed, which predate the specified versions of the compiler.
4849

4950
::: moniker range=">= msvc-160"
5051

52+
## Warnings introduced in Visual Studio 2019 version 16.11 (compiler version 19.29.30100.0)
53+
54+
These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.29.30000`**.
55+
56+
| Warning | Message |
57+
|--|--|
58+
| C5247 | `section 'section-name' is reserved for C++ dynamic initialization. Manually creating the section will interfere with C++ dynamic initialization and may lead to undefined behavior` |
59+
| C5248 | `section 'section-name' is reserved for C++ dynamic initialization. Variables manually put into the section may be optimized out and their order relative to compiler generated dynamic initializers is unspecified` |
60+
5161
## Warnings introduced in Visual Studio 2019 version 16.10 (compiler version 19.29.30000.0)
5262

5363
These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.29`**.

0 commit comments

Comments
 (0)