C ++ variable naming rules

Source: Internet
Author: User

Link: http://www.cnblogs.com/zhangpengshou/archive/2008/10/19/1314424.html

A ArrayArray

B bool (INT)Boolean(Integer)

By unsigned char (byte)Unsigned characters(Bytes)

C charCharacter(Bytes)

CB count of bytesBytes

Cr color reference valueColor(Reference)Value

CX count of X (short) x.(Short integer)

Dw dword (unsigned long)Double-Character(Unsigned long integer)

F flags (usually multiple bit values)Flag(Generally, there are multiple digits.)

FN FunctionFunction

G _ globalGlobal

H handleHandle

I integerInteger

L longLong Integer

LP long pointerLong pointer

M _ data member of a classData member of a class

N short intShort integer

P pointerPointer

S stringString

SZ zero terminated stringTo0String ending

TM text MetricText rules

U unsigned intUnsigned integer

Ul unsigned long (ulong)Unsigned long integer

W word (unsigned short)Unsigned short integer

X, y x, Y coordinates (short)Coordinate value/Short integer

V voidNull

For project global variablesG _Class member variablesM _If the function is large, you can useL _It is used to show that it is a local variable.

PrefixTypeExample

G _Global VariablesG_servers

CClass or structCdocument,Cprintinfo

M _Member variablesM_pdoc,M_ncustomers

VCCommon prefix list:

PrefixTypeDescriptionExample

Ch char 8CharactersChgrade

Ch tchar 16BitUnicodeType characterChname

B boolBoolean variableBenabled

N intINTEGER (the size is determined by the operating system)Nlength

N uintUnsigned integer (the size is determined by the operating system)Nlength

W word 16Unsigned integerWpos

L long 32Bitwise signed integerLoffset

Dw dword 32Unsigned integerDwrange

P * ambient Memory Model pointerMemory Module pointer and pointer variablePdoc

LP far *Long pointerLpdoc

Lpsz lpstr 32Bit String pointerLpszname

Lpsz lpcstr 32Bitwise constant string pointerLpszname

Lpsz lpctstr 32BitUnicodeType constant pointerLpszname

H handle windowsObject handleHwnd

Lpfn (* fN )()Callback function pointerCallback far pointer to callback function lpfnabort

WindowsAbbreviation of Object Name:

WindowsObjectExample variableMFCClassExample object

Hwnd; cwnd * pwnd;

Hdlg; cdialog * pdlg;

HDC; CDC * PDC;

Hgdiobj; cgdiobject * pgdiobj;

Hpen; cpen * ppen;

Hbrush; cbrush * pbrush;

Hfont; cfont * pfont;

Hbitmap; cbitmap * pbitmap;

Hpalette; cpalette * ppalette;

Hrgn; crgn * prgn;

Hmenu; cmenu * pmenu;

Hwnd hctl; cstatic * pstatic;

Hwnd hctl; cbutton * pbtn;

Hwnd hctl; cedit * pedit;

Hwnd hctl; clistbox * plistbox;

Hwnd hctl; ccombobox * pcombobox;

VCName List of commonly used macro definitions:

PrefixSymbol typeSymbol exampleRange

Idr _Identifies the type of Resource SharingIdr_mainframe 1 ~ 0x6fff

IDD _Dialog Box resources (Dialog)Idd_spell_check 1 ~ 0x6fff

Hidd _Context help based on the dialog boxHidd_spell_check 0x20001 ~ 0x26ff

Idb _Bitmap resources (Bitmap)Idb_company_logo 1 ~ 0x6fff

IDC _Cursor Resource (Cursor)Idc_penpencil 1 ~ 0x6fff

Idi _Icon Resource (Icon)Idi_notepad 1 ~ 0x6fff

Id _,Idm _Command item in the toolbar or menu barId_tools_spelling 0x8000 ~ 0 xdfff

Hid _Command context helpHid_tools_spelling 0x18000 ~ 0x1dfff

IDP _Text resource prompt in the message boxIdp_invalid_partno 8 ~ 0 xdfff

Hidp _Message Box context helpHidp_invalid_partno 0x30008 ~ 0x3dfff

IDS _String Resource (String)Ids_copyright 1 ~ 0x7fff

IDC _Resource Control in the dialog boxIdc_recalc 8 ~ 0 xdfff

Microsoft MFCMacro naming rules

NameType

_ AfxdllUnique dynamic Connection Library (Dynamic Link Library,DLL) Version

_ AlphaCompile onlyDEC AlphaProcessor

_ DebugIncluding debugging versions for Diagnosis

_ MBCSCompile multi-byte character sets

_ UnicodeIn an applicationProgramOpenUnicode

Afxapi MFCProvided Functions

CallbackFunction called back by pointer

Library identifier name Method

IdentifierValue and meaning

U ANSI(N) OrUnicode(U)

DDebugging or release:D =Debug; ignore the identifier as release

Static library version naming rules

LibraryDescription

Nafxcwd. LibDebug version:MFCStatic Connection Library

Nafxcw. LibRelease Version:MFCStatic Connection Library

Uafxcwd. LibDebug version:UnicodeSupportedMFCStatic Connection Library

Uafxcw. LibRelease Version:UnicodeSupportedMFCStatic Connection Library

Dynamic Connection Library naming rules

NameType

_ AfxdllUnique dynamic Connection Library (DLL) Version

Winapi windowsProvided Functions

Windows. hNew naming rules

TypeDefinition description

WinapiUsed inAPIDeclaredFar PascalLocation. If you are writingAPIPopulation pointDLL, You canAPIUse this type

CallbackUsed in application callback programs, such as Windows and dialog boxesFar PascalLocation

LpcstrAndLpstrSame,LpcstrUsed for read-only string pointers. Its definition is similar (Const char far *)

UintThe portable unsigned integer type, whose size is determined by the host environment (Windows NTAndWindows 9xIs32Bit); it isUnsigned intSynonym

LresultType of window program return value

LparamStatementLparamType used,LparamIs the fourth parameter of the window program.

WparamStatementWparamType used,WparamIs the third parameter of the window program.

LpvoidCommon pointer type, and (Void *) Same, can be used to replaceLpstr

A ArrayArray

B bool (INT)Boolean(Integer)

By unsigned char (byte)Unsigned characters(Bytes)

C charCharacter(Bytes)

CB count of bytesBytes

Cr color reference valueColor(Reference)Value

CX count of X (short) x.(Short integer)

Dw dword (unsigned long)Double-Character(Unsigned long integer)

F flags (usually multiple bit values)Flag(Generally, there are multiple digits.)

FN FunctionFunction

G _ globalGlobal

H handleHandle

I integerInteger

L longLong Integer

LP long pointerLong pointer

M _ data member of a classData member of a class

N short intShort integer

P pointerPointer

S stringString

SZ zero terminated stringTo0String ending

TM text MetricText rules

U unsigned intUnsigned integer

Ul unsigned long (ulong)Unsigned long integer

W word (unsigned short)Unsigned short integer

X, y x, Y coordinates (short)Coordinate value/Short integer

V voidNull

For project global variablesG _Class member variablesM _If the function is large, you can useL _It is used to show that it is a local variable.

PrefixTypeExample

G _Global VariablesG_servers

CClass or structCdocument,Cprintinfo

M _Member variablesM_pdoc,M_ncustomers

VCCommon prefix list:

PrefixTypeDescriptionExample

Ch char 8CharactersChgrade

Ch tchar 16BitUnicodeType characterChname

B boolBoolean variableBenabled

N intINTEGER (the size is determined by the operating system)Nlength

N uintUnsigned integer (the size is determined by the operating system)Nlength

W word 16Unsigned integerWpos

L long 32Bitwise signed integerLoffset

Dw dword 32Unsigned integerDwrange

P * ambient Memory Model pointerMemory Module pointer and pointer variablePdoc

LP far *Long pointerLpdoc

Lpsz lpstr 32Bit String pointerLpszname

Lpsz lpcstr 32Bitwise constant string pointerLpszname

Lpsz lpctstr 32BitUnicodeType constant pointerLpszname

H handle windowsObject handleHwnd

Lpfn (* fN )()Callback function pointerCallback far pointer to callback function lpfnabort

WindowsAbbreviation of Object Name:

WindowsObjectExample variableMFCClassExample object

Hwnd; cwnd * pwnd;

Hdlg; cdialog * pdlg;

HDC; CDC * PDC;

Hgdiobj; cgdiobject * pgdiobj;

Hpen; cpen * ppen;

Hbrush; cbrush * pbrush;

Hfont; cfont * pfont;

Hbitmap; cbitmap * pbitmap;

Hpalette; cpalette * ppalette;

Hrgn; crgn * prgn;

Hmenu; cmenu * pmenu;

Hwnd hctl; cstatic * pstatic;

Hwnd hctl; cbutton * pbtn;

Hwnd hctl; cedit * pedit;

Hwnd hctl; clistbox * plistbox;

Hwnd hctl; ccombobox * pcombobox;

VCName List of commonly used macro definitions:

PrefixSymbol typeSymbol exampleRange

Idr _Identifies the type of Resource SharingIdr_mainframe 1 ~ 0x6fff

IDD _Dialog Box resources (Dialog)Idd_spell_check 1 ~ 0x6fff

Hidd _Context help based on the dialog boxHidd_spell_check 0x20001 ~ 0x26ff

Idb _Bitmap resources (Bitmap)Idb_company_logo 1 ~ 0x6fff

IDC _Cursor Resource (Cursor)Idc_penpencil 1 ~ 0x6fff

Idi _Icon Resource (Icon)Idi_notepad 1 ~ 0x6fff

Id _,Idm _Command item in the toolbar or menu barId_tools_spelling 0x8000 ~ 0 xdfff

Hid _Command context helpHid_tools_spelling 0x18000 ~ 0x1dfff

IDP _Text resource prompt in the message boxIdp_invalid_partno 8 ~ 0 xdfff

Hidp _Message Box context helpHidp_invalid_partno 0x30008 ~ 0x3dfff

IDS _String Resource (String)Ids_copyright 1 ~ 0x7fff

IDC _Resource Control in the dialog boxIdc_recalc 8 ~ 0 xdfff

Microsoft MFCMacro naming rules

NameType

_ AfxdllUnique dynamic Connection Library (Dynamic Link Library,DLL) Version

_ AlphaCompile onlyDEC AlphaProcessor

_ DebugIncluding debugging versions for Diagnosis

_ MBCSCompile multi-byte character sets

_ UnicodeOpenUnicode

Afxapi MFCProvided Functions

CallbackFunction called back by pointer

Library identifier name Method

IdentifierValue and meaning

U ANSI(N) OrUnicode(U)

DDebugging or release:D =Debug; ignore the identifier as release

Static library version naming rules

LibraryDescription

Nafxcwd. LibDebug version:MFCStatic Connection Library

Nafxcw. LibRelease Version:MFCStatic Connection Library

Uafxcwd. LibDebug version:UnicodeSupportedMFCStatic Connection Library

Uafxcw. LibRelease Version:UnicodeSupportedMFCStatic Connection Library

Dynamic Connection Library naming rules

NameType

_ AfxdllUnique dynamic Connection Library (DLL) Version

Winapi windowsProvided Functions

Windows. hNew naming rules

TypeDefinition description

WinapiUsed inAPIDeclaredFar PascalLocation. If you are writingAPIPopulation pointDLL, You canAPIUse this type

CallbackUsed in application callback programs, such as Windows and dialog boxesFar PascalLocation

LpcstrAndLpstrSame,LpcstrUsed for read-only string pointers. Its definition is similar (Const char far *)

UintThe portable unsigned integer type, whose size is determined by the host environment (Windows NTAndWindows 9xIs32Bit); it isUnsigned intSynonym

LresultType of window program return value

LparamStatementLparamType used,LparamIs the fourth parameter of the window program.

WparamStatementWparamType used,WparamIs the third parameter of the window program.

LpvoidCommon pointer type, and (Void *) Same, can be used to replaceLpstr

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.