From 97ddff83f3b569699224486303e8ed5c9d2145b1 Mon Sep 17 00:00:00 2001 From: Brother Beer Date: Thu, 3 Feb 2022 11:29:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=82=BC=E8=BE=9E=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- c-cpp-rules.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/c-cpp-rules.md b/c-cpp-rules.md index 3e97661..0927e98 100644 --- a/c-cpp-rules.md +++ b/c-cpp-rules.md @@ -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 个字符。 @@ -3818,7 +3818,7 @@ using namespace std; // Non-compliant ``` 下例展示的问题是头文件不同的包含顺序竟导致同一函数产生了不同的行为: ``` -// a.h +// In a.h void foo(char); namespace ns { @@ -3829,11 +3829,11 @@ 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" @@ -3841,7 +3841,7 @@ void fun1() { bar(); // ‘bar’ calls ‘foo(char)’ } -// b.cpp +// In b.cpp #include "b.h" #include "a.h"