จากเอกสาร MSDN และมาตรฐาน C++:
ห้ามใช้ (Reserved for implementation)
- Double underscore ใดๆ:
__foo,__FOO,foo__bar(ทุก scope) - Leading underscore + ตัวใหญ่:
_FOO,_Bar(ทุก scope) - Leading underscore + ตัวเล็ก:
_foo,_bar(เฉพาะ global/file scope)
ควรหลีกเลี่ยง (Reserved prefixes/suffixes)
- Prefixes:
LC_,SIG_,E(error codes),is+ ตัวใหญ่ (ctype functions) - Suffixes:
_t(POSIX types)
ปลอดภัย (Safe to use)
- Underscore ระหว่างชื่อ:
my_variable,foo_bar - Underscore ท้ายชื่อ:
variable_,member_(นิยมใช้สำหรับ member variables) - Leading underscore + ตัวเล็กใน local scope (function/class scope): ปลอดภัย
แนวทางปฏิบัติดี: ใช้ member_ หรือ m_member สำหรับ data members, หลีกเลี่ยบ leading underscore ทั้งหมด