Hungarian Notation

Hungarian Notation is a variable-naming convention so called in the honor of the legendary Microsoft programmer Charles Simonyi. According to this convention the variable name begins with a lower case letter or letters that denotes the data type of the variable. For example, the sz prefix in szCmdLine stands for ‘string terminated by zero’; the prefix h in hInstance stands for ‘handle’; the prefix n in nCmdShow stands for int. Prefixes are often combined to form other prefixes, as lpsz in lpszCmdLine stands for ‘long pointer to a zero terminated string’. Though basically this notation is a good idea nowadays its usage is discouraged. This is because when a transition happens from say a 16-bit code to 32-bit code then a whole lot of variable names have to be changed. For example, suppose the 16-bit code used 2-byte and 4-byte integer variables called wParam and lParam, where w indicated a 16-bit integer (word) and a 32-bit integer (long) respectively. When this code is ported to a 32-bit environment wParam had to be changed to lParam since in this environment every integer is 4 bytes long

C Under Windows

  • Under Windows an integer is four bytes long. To use a two-byte integer pre-qualify it with short.
  • Under Windows a pointer is four bytes long
  • Windows programming involves a heavy usage of typedefs
  • DOS uses a Sequential Programming Model, whereas, Windows uses an Event Driven Programming Model.
  • Entry point of every Windows program is a function called WinMain( )
  • Windows does not permit direct access to memory or hardware devices
  • Windows uses a Demand-based Virtual Memory Model to manage memory.
  • Under Windows there is two-way communication between the program and the OS.
  • Windows maintains a system message queue common for all applications
  • Windows maintains an application message queue per running application
  • Calling convention decides the order in which the parameters are passed to a function and whether the calling function or the called function clears the stack.
  • Commonly used calling conventions are __cdecl and __stdcall
  • Hungarian notation though good its usage is not recommended any more

Leave a Comment