Skip to content

Commit

Permalink
精炼辞句
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherbeer authored Feb 3, 2022
1 parent d70e27d commit 97ddff8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions c-cpp-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -3681,12 +3681,12 @@ ID_nameTooShort     :bulb: global suggestion
示例:
```
// In global scope
const int i = 0; // Non-compliant, name too short
typedef int t; // Non-compliant, name too short
class A { .... }; // Non-compliant, name too short
const int i = 0; // Non-compliant, name too short
typedef int t; // Non-compliant, name too short
class A { .... }; // Non-compliant, name too short
int foo(int i) {
return i + i; // Confusing
return i + i; // Confusing
}
```
名称适用的作用域范围越广,其长度也应该越长,建议全局名称长度不小于 3 个字符。
Expand Down Expand Up @@ -3818,7 +3818,7 @@ using namespace std; // Non-compliant
```
下例展示的问题是头文件不同的包含顺序竟导致同一函数产生了不同的行为:
```
// a.h
// In a.h
void foo(char);
namespace ns {
Expand All @@ -3829,19 +3829,19 @@ inline void bar() {
foo(0);
}
// b.h
// In b.h
namespace ns {}
using namespace ns;
// a.cpp
// In a.cpp
#include "a.h"
#include "b.h"
void fun1() {
bar(); // ‘bar’ calls ‘foo(char)’
}
// b.cpp
// In b.cpp
#include "b.h"
#include "a.h"
Expand Down

0 comments on commit 97ddff8

Please sign in to comment.