Skip to content

Commit 5a975c5

Browse files
author
Colin Robertson
authored
Update c6389.md
Clarify code samples.
1 parent 9aad1eb commit 5a975c5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/code-quality/c6389.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,31 @@ The rule is an experimental rule that must be explicitly enabled in a rule set f
1919
```cpp
2020
// A.h
2121
struct X;
22+
```
2223

24+
```
2325
// A.cpp
26+
#include "A.h"
2427
2528
// Not flagged, declared in a header file.
2629
struct X { int x; };
2730
2831
struct Y { double y; }; // warning: Move 'Y' to anonymous namespace or put a forward declaration in a common header included in this file.
2932
30-
void f(); // warning: Move 'Y' to anonymous namespace or put a forward declaration in a common header included in this file.
33+
void f(); // warning: Move 'f' to anonymous namespace or put a forward declaration in a common header included in this file.
3134
```
3235

33-
To resolve this issue:
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:
3437

3538
```cpp
3639
// A.h
3740
struct X;
3841
void f();
42+
```
3943

44+
```cpp
4045
// A.cpp
46+
#include "A.h"
4147

4248
// Not flagged, declared in a header file.
4349
struct X { int x; };
@@ -48,5 +54,4 @@ namespace {
4854

4955
// Not flagged, declared in a header file.
5056
void f();
51-
5257
```

0 commit comments

Comments
 (0)