You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
structX;
22
+
```
23
+
24
+
```cpp
25
+
// A.cpp
26
+
#include"A.h"
27
+
28
+
// Not flagged, declared in a header file.
29
+
structX { 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:
0 commit comments