(See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs600/html/hunganotat.asp)
The Hungarian nomenclature is a naming specification for a variable, function, object, prefix, macro definition, and other types of symbols. The main idea of Hungarian nomenclature is: adding prefix in variables and function names to enhance people's understanding of procedures. It is used by a Hungarian in Microsoft, and it is gradually popular in Microsoft, and promotes Windows developers around the world. Prophet Petzold uses Hungarian notes in his masterpiece "programing windows". Because the book has great influence, he indirectly became the parity of Hungarian notes. The Hungarian nomenclature will be introduced below.
First, the variable is named
The variable name is coupled to the prefix indicating its type (as follows), if the variable name consists of several words, then each word first letter is capitalized, disable underscore _
A array array
B Bool (int) Boolean (integer)
By unsigned char (byte) No symbolic characters (bytes)
C char character (byte)
CB Count of bytes bytes
Cr Color Reference Value Color (Reference) Value
CX Count of X (Short) X Collection (Short Integer)
DW DWORD (unsigned long) double word (no symbol length)
f Flags (USUALLY MULTIPLE BIT VALUES) Sign (generally multiple values)
Fn function function
G_ Global Global
H Handle handle
i integer integer
l Long long integer
LP Long Pointer long pointer
M_ Data Member of a Class A class of data members
N Short Int short integer
P P Pointer Pointer S String Strings
SZ ZERO TERMINATED STRING string ends with 0
TM Text Metric Text Rules
u Unsigned int unsigned integer
UL unsigned long (ulong) unsigned long integer
W Word (unsigned short) no symbol short integer
X, Y X, Y Coordinates (Short) Coordinate Value / Short Integer
v void empty
Second, the function is named
Rules are named with variables, just do not need to add prefixes.
Third, type and constant naming
The characters are all uppercase, which can be used underline.
Fourth, the name of the class
With C as prefix, the first letter of each word is capitalized.
V. VC common prefix list:
Prefix type description example
CH char 8-bit character chgrade
CH Tchar 16 Unicode Type Characters Chname
B Bool Boolean Variable Benabled
n int integer (whose size is determined by operating system) NLENGTH
N uint No symbol integer (its size is determined by operating system) NLENGTH
W word 16-bit unsigned integer WPOS
l Long 32 with symbolic Loffset
DW DWORD 32-bit DWRANGEP * AMBIENT MEMORY MODEL POINTER Memory Module Pointer, Pointer Variable PDOC
LP FAR * long pointer LPDOC
LPSZ LPSTR 32-bit string pointer lpszname
LPSZ LPCSTR 32-bit constant string pointer lpszname
LPSZ LPCTSTR 32-bit Unicode Type constant pointer lpszname
H H Handle Windows Object Handle HWND
LPFN (* fn) () callback function pointer LPFNABORT
A section of code to comply with code style and Hungarian nomenclature is as follows:
1 #include "SY.H"
2 extern int * RGWDIC;
3 Extern Int Bsymac;
4 struct sy * psysz (char SZ [])
6 {
7 char * pch;
8 int CCH;
9 Struct Sy * psy, * psycreate ();
10 int * PBSY;
11 int CWSZ;
12 Unsigned Whash = 0;
13 PCH = SZ;
14 While (* PCH! = 0)
15 Whash = Whash <> 11 * PCH ;
16 cCH = PCH-SZ;
17 pbsy = & rgbsyhash [(whash & 077777)% cWhash];
18 for (; * pbsy! = 0; PBSY = & psy-> bsynext)
19 {
20 char * szsy;
21 szsy = (psy = (struct sy *) & rgwdic [* pbsy]) -> sz;
22 PCH = SZ;
23 While (* PCH == * Szsy ) 24 {
25 if (* PCH == 0)
26 return (psy);
27}
28}
29 cwsz = 0;
30 IF (cch> = 2)
31 CWSZ = CCH-2 / SizeOf (int) 1;
32 * PBSY = (int *) (psy = psycreate (cwsy cwsz)) - RGWDIC;
33 Zero ((int *) psy, cwsy);
34 BLTBYTE (SZ, Psy-> SZ, CCH 1);
35 Return (PSY);
36}