From http://dev.firnow.com/course/3_program/c++/cppjs/20090403/163802.html
1. Differences between FALSE/TRUE and false/true:
False/true is the new keyword in the Standard C ++ language, while FALSE/TRUE is through # define, which is used to solve the environment difference between the program in C and C ++, the following values are FALSE/TRUE in windef. h definition:
# Ifndef FALSE <br/> # define FALSE 0 <br/> # endif <br/> # ifndef TRUE <br/> # define TRUE 1 <br/> # endif
That is to say, FALSE/TRUE is the int type, while false/true is the bool type. So they are different, but we do not feel this way in use, because C ++ will help you perform implicit conversion.
2. Differences between the bool size and the BOOL size:
Bool occupies 1 byte in C ++, while BOOL is of the int type. The size of the int type depends on the specific environment. So: false/true only occupies 1 byte, while TRUE/FALSE indicates that the following BOOL is in windef. definition in h: typedef int BOOL;
3. Differences between NULL and 0:
Let's take a look at the definition of NULL in windef. h:
# Ifndef NULL <br/> # ifdef _ cplusplus // This indicates that the program is compiled using C ++ <br/> # define NULL 0 <br/> # else <br/> # define NULL (void *) 0) <br/> # endif
So there is no difference between them, but a forced type conversion will be performed in C.
4. Differences between HINSTANCE and HMODULE:
Definition in windef. h:
Typedef hinstance hmodule;/* HMODULEs can be used in place of HINSTANCEs */
5. CALLBACK, the essence of WINAPI:
Definition in windef. h:
# Undef far <br/> # undef near <br/> # undef pascal <br/> # define far <br/> # define near <br/> # if (! Defined (_ MAC) & (_ MSC_VER> = 800) | defined (_ STDCALL_SUPPORTED )) <br/> # define pascal _ stdcall <br/> # else <br/> # define pascal <br/> # endif <br/> # if defined (DOSWIN32) | defined (_ MAC) <br/> # define cdecl _ cdecl <br/> # ifndef CDECL <br/> # define CDECL _ cdecl <br/> # endif <br/> # else <br/> # define cdecl <br/> # ifndef CDECL <br/> # define CDECL <br/> # endif <br/> # ifdef _ MAC <br /># define callback pascal <br/> # define winapi cdecl <br/> # define winapiv cdecl <br/> # define apientry winapi <br/> # define apiprivate cdecl <br /># ifdef _ 68K _ <br/> # define PASCAL _ pascal <br/> # else <br/> # define PASCAL <br/> # endif <br/> # elif (_ MSC_VER >=800) | defined (_ STDCALL_SUPPORTED) <br/> # define CALLBACK _ stdcall <br/> # define WINAPI _ stdcall <br/> # define WINAPIV _ cdecl <br/> # define apientry winapi <br /># define APIPRIVATE _ stdcall <br/> # define PASCAL _ stdcall <br/> # else <br/> # define CALLBACK <br/> # define WINAPI <br /># define WINAPIV <br/> # define apientry winapi <br/> # define APIPRIVATE <br/> # define PASCAL <br/> # endif
6. Definitions of some common types:
Definition in windef. h:
Typedef uint wparam; <br/> typedef long lparam; <br/> typedef long lresult; <br/> typedef int; <br/> typedef unsigned int uint; <br/> typedef unsigned long DWORD; <br/> typedef int BOOL; <br/> typedef unsigned char BYTE; <br/> typedef unsigned short WORD; <br/> typedef float FLOAT; <br/> typedef unsigned long ULONG; <br/> typedef unsigned short USHORT; <br/> typedef unsigned char UCHAR; <br/> typedef char * PSZ;
7. essence of common Window resource types:
Definition in windef. h:
DECLARE_HANDLE (HPEN); <br/> DECLARE_HANDLE (HBITMAP); <br/> DECLARE_HANDLE (HBRUSH); <br/> DECLARE_HANDLE (HDC ); <br/> DECLARE_HANDLE (HFONT); <br/> DECLARE_HANDLE (HICON); <br/> DECLARE_HANDLE (HMENU); <br/> DECLARE_HANDLE (HMETAFILE ); <br/> DECLARE_HANDLE (HINSTANCE); <br/> DECLARE_HANDLE (HPALETTE); <br/> typedef word atom; <br/> typedef handle hglobal; <br/> typedef handle hlocal; <br/> typedef handle globalhandle; <br/> typedef handle localhandle; <br/> typedef hicon hcursor; /* HICONs & HCURSORs are polymorphic */<br/> typedef dword colorref;
In Windows X. h:
# Define DECLARE_HANDLE32 DECLARE_HANDLE <br/> penwin. h: <br/> # ifndef DECLARE_HANDLE32 <br/> # define DECLARE_HANDLE32 (name)/<br/> struct name ##__ {int unused ;}; /<br/> typedef const struct name ##__ FAR * name <br/> # endif //! DECLARE_HANDLE32
6. Related preprocessing macros of the compiled versions of PlatForm:
| Macro |
Description |
| _ Cplusplus |
Defined for C ++ programs only. |
| _ MFC_VER |
Defines the MFC version. Defined as 0x0421 for Microsoft Foundation Class Library 4.21. Always defined. |
| _ MSC_VER |
Defines the compiler version. Defined as 1200 for Microsoft Visual C ++ 6.0. Always defined. |
| _ WIN32 |
Defined for applications for Win32. Always defined. |