Variable naming – Hungarian naming rules – C language zero-based tutorial

Ape said programmingThe 2021-07-31 08:14:43 collection

Variable naming Hungarian naming rules C language naming C language variable naming C language tutorial

Copyright notice: This article is originally published BY the blogger. It follows the COPYRIGHT agreement CC 4.0 BY-SA. Please attach the link of the original source and this statement.

This paper links: blog.csdn.net/ZhaDeNianQu…

Edit the copyright

directory

  • 1. Attributes
  • 2. Type section
  • 3. Description
  • 4. Naming conventions for MFC, handles, controls and structures
  • 5. Variable naming conventions
  • 6. Library identifier naming
  • 7. For example
  • 8. I guess you like it

C/C++ learning Directory >> C language basics

Hungarian nomenclature is a programming naming convention. The basic principle is: variable name = attribute + type + object description, where each object name must have a clear meaning, can be the full name of the object or part of the name. Be based on principles that are easy to remember and easy to understand. It’s important to keep the name consistent.

1.Properties section

G_ global variable c_ constant m_ c++ class member variable s_ static variableCopy the code

2.Type part

Array A Pointer P Long Pointer Long Pointer function fn Invalid V handle H Long integer type L Boolean B floating point type F double word DW string sz Short integer type n Double precision floating point D count C (usually CNT) character Ch (usually c) integer I (usually N) byte by word w real type r unsigned UCopy the code

3.Describe some

Max Max Min Init Temporary variable T (or Temp) Source object Src Destination object DestCopy the code

4. Naming conventions for MFC, handles, controls and structures

Windows type sample variable MFC type sample variable HWND HWND CWnd* pWnd HDLG HDLG CDialog* pDlg HDC HDC CDC* pDC HGDIOBJ HGDIOBJ CGdiObject* pGdiObj HPEN hPen CPen* pPen HBRUSH hBrush CBrush* pBrush HFONT hFont CFont* pFont HBITMAP hBitmap CBitmap* pBitmap HPALETTE hPaltte CPalette* pPalette HRGN hRgn CRgn* pRgn HMENU hMenu CMenu* pMenu HWND hCtl CState* pState HWND hCtl CButton* pButton HWND hCtl CEdit* pEdit HWND hCtl CListBox* pListBox HWND hCtl CComboBox* pComboBox HWND hCtl CScrollBar* pScrollBar HSZ hszStr CString pStr POINT pt CPoint pt SIZE size CSize size RECT rect CRect rectCopy the code

5. Variable naming conventions

ChGrade chtchar if _UNICODE is defined, ChName B BOOL Boolean value bEnable n int Integer (its size depends on the OPERATING system) nLengt n UINT Unsigned value (its size depends on the operating system) nHeight W WORD 16-bit unsigned value wPos L LONG 32-bit signed integer lOffset dw DWORD 32-bit unsigned integer dwRange P * pointer pDoc LP FAR* FAR pointer lpszName LPSZ LPSTR 32-bit string pointer lpszName LPSZ LPCSTR 32-bit constant string pointer lpszName LPSZ LPCTSTR if _UNICODE is defined, LpszName H Handle Windows object handle hWnd LPFN callback Remote pointer to the callback function prefix Symbol Type Instance Range IDR_ Multiple resource sharing identifiers of different types IDR_MAIINFRAME 1 to 0x6FFF IDD_ dialog box resources IDD_SPELL_CHECK 1 to 0x6FFF HIDD_ Dialog box resources Help context HIDD_SPELL_CHECK 0x20001 to 0x26FF IDB_ Bitmap resources IDB_COMPANY_LOGO 1 to 0x6FFF IDC_ Cursor resources IDC_PENCIL 1 to 0x6FFF IDI_ Icon resources IDI_NOTEPAD 1 to 0x6FFF ID_ Commands from the menu item or toolbar ID_TOOLS_SPELLING 0x8000 to 0xDFFF HID_ Command Help Context HID_TOOLS_SPELLING 0x18000 to 0x1DFFF IDP_ Message box displays IDP_INVALID_PARTNO 8 to 0xDEEF HIDP_ message box Help Context HIDP_INVALID_PARTNO 0x30008 to 0x3DEFF IDS_ String Resources IDS_COPYRIGHT 1 to 0x7EEF Control in the IDC_ dialog box IDC_RECALC 8 to 0xDEEF Microsoft MFC macro naming convention: Name Type _AFXDLL unique Dynamic Link Library, DLL) version _ALPHA only compiles DEC Alpha processor _DEBUG debug version including diagnostics _MBCS compiles multi-byte character sets _UNICODE opens the function CALLBACK provided by Unicode AFXAPI MFC in an application A function that is called back through a pointerCopy the code

6. Library identifier naming

Identifier Values and meanings u ANSI (N) or Unicode (u) d Debug or release: d = debug, ignoring identifier for release. Static library version naming conventions: LIB: Uafxcwd. LIB: Uafxcwd. LIB: Uafxcwd. LIB: Uafxcwd. LIB: MFC static connection library with Unicode support Dynamic connection library naming specification: Name Type _AFXDLL Unique dynamic connection library (DLL) version WINAPI Windows provided by the function Windows.h new naming specification: The type definition describes where WINAPI is used in FAR PASCAL in the API declaration. If you are writing a DLL with exported API population points, you can use this type CALLBACK in your OWN API. LPCSTR is the same as LPSTR except that LPCSTR is used for read-only string Pointers. Its definition is similar to (const char FAR*) UINT portable unsigned integer type. The size is determined by the host environment (32-bit for Windows NT and Windows 9X); It's a synonym for unsigned int LRESULT the type that the window program returns LPARAM declares the type that LPARAM uses, LPARAM is the fourth argument to the window program WPARAM declares the type that WPARAM uses, WParam is the third argument to the window program LPVOID. It is the same as void * and can be used instead of LPSTRCopy the code

7. For example

HWND: H indicates the type description, indicating the handle. WND indicates the variable object description, indicating the window. HWND indicates the window handle. PfnEatApple: PFN is a type description and represents a pointer to a function. EatApple is a variable object description, so it represents a function pointer variable to EatApple. G_cch: g_ is the attribute description, representing the global variable, and c and ch are the count type and character type respectively, representing the variable type together. The object description is ignored here, so it represents a global variable that counts characters. Naming conventions for MFC, handles, controls, and structures: Windows type sample variables; MFC class sample variable HWND HWND; The CWnd * pWnd. HDLG HDLG; CDialog * pDlg; HDC HDC. The CDC * pDC. HGDIOBJ HGDIOBJ; The CGdiObject * pGdiObj; HPEN HPEN; CPen * pPen; HBRUSH HBRUSH; PBrush CBrush *; HFONT HFONT; CFont * pFont; HBITMAP HBITMAP; CBitmap * pBitmap; HPALETTE hPaltte; CPalette * pPalette; HRGN HRGN; CRgn * pRgn; HMENU HMENU; CMenu * pMenu; The HWND hCtl; CState * pState; The HWND hCtl; CButton * pButton; The HWND hCtl; CEdit * pEdit; The HWND hCtl; CListBox * pListBox; The HWND hCtl; CComboBox * pComboBox; The HWND hCtl; CScrollBar * pScrollBar; HSZ hszStr; Cstrings pStr; POINT pt; CPoint pt; The SIZE the SIZE; CSize size; The RECT the RECT. CRect the rect.Copy the code

8. I guess you like it

  1. Install Visual Studio
  2. Install the Visual Studio plug-in, Visual Assist
  3. Visual Studio 2008 uninstall
  4. Visual Studio 2003/2015 Uninstall
  5. Set the Visual Studio font/background/line number
  6. C Hello World
  7. C code comments
  8. C data type/variable type
  9. C language variable declaration and definition
  10. Variable naming – Hungarian naming rules

Variable naming — Hungarian naming rules

This article is published by the blog – Ape Say Programming Ape Say programming!