Skip to content

Commit c40b196

Browse files
committed
Merge branch 'patch-3' of https://github.com/Xazax-hun/cpp-docs into public-3187
2 parents ec5f24c + e0e0429 commit c40b196

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

docs/code-quality/c6389.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 intended to help with reducing the visibility of certain symbols and 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 is 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+
This is an experimental rule that needs to be enabled in a ruleset file explicitly to work. More information about rulesets can be found [here](https://docs.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules).
16+
17+
## Example
18+
```cpp
19+
// A.h
20+
struct X;
21+
22+
// A.cpp
23+
24+
// Not flagged, declared in a header file.
25+
struct X { int x; };
26+
27+
struct Y { double y; }; // warning: Move 'Y' to anonymous namespace or put a forward declaration in a common header included in this file.
28+
29+
void f(); // warning: Move 'Y' to anonymous namespace or put a forward declaration in a common header included in this file.
30+
```
31+
To resolve this issue:
32+
```cpp
33+
// A.h
34+
struct X;
35+
void f();
36+
37+
// A.cpp
38+
39+
// Not flagged, declared in a header file.
40+
struct X { int x; };
41+
42+
namespace {
43+
struct Y { double y; };
44+
} // anonymous namespace
45+
46+
// Not flagged, declared in a header file.
47+
void f();
48+
49+
```

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

0 commit comments

Comments
 (0)