本身命名规范并没有统一的标准,但是还是会有一些类似于 i 作为迭代次数,T 作为模板这样不成文又广为受用规则,尽可能多的熟悉这些规则,在阅读开源项目时能获得得到更多的信息,看的更明白一些。
参考文档:
Google 开源项目风格指南 (中文版)
Windows Coding Conventions
变量命名
DrivePose_t* pPose;//DriverPose_t的_t结尾表示type,说明DriverPose_t是个类型
//pPose的p开头表示pointer,说明pPose是个指针
int g_Mode;//g_开头表示global,说明g_Mode全局变量
int m_Socket;//m_表示member,成员变量
const char* k_Settings_RenderWidth;//k_表示const或constexpr,常量
bool bSwitch;//b表示bool
// 涉及windows编程会碰到很多h,lp,w开头的变量
HANDLE hTexture;//h表示handle,此变量为一句柄
/*
The LP prefix has been preserved to make it easier to port 16-bit code to 32-bit Windows. Today there is no distinction, and these pointer types are all equivalent. Avoid using these prefixes; or if you must use one, then use P.
*/
RECT* rect; // Pointer to a RECT structure.
LPRECT rect; // The same, LP意思是Long Pointer,是16位windows系统的遗留产物,现在已经与p- prefix没有区别
PRECT rect; // Also the same, P意识是Pointer
// dw is short for DWORD(unsigned 32bits) and w is short for WORD.(unsigned 16bits)
wchar_t* // Unicode字符串(w表示wide,意思是wide characters16位) 与之对应的是ANSI字符串char*
PCSTR or LPCSTR // 表示const char*
PWSTR or LPWSTR // 表示wchar_t*
// To declare a wide-character literal or a wide-character string literal, put L before the literal.
wchar_t a = L'a';
wchar_t *str = L"hello";