將一個Windows程序移植到Linux上,發(fā)現(xiàn)兩個操作系統(tǒng)對很多數(shù)據(jù)類型的命名方式區(qū)別很大,比如Windows下對于無符號數(shù)據(jù)類型一般用U+x的方式,像UINT、UCHAR、ULONG,而Linux上就要中規(guī)中矩,都是unsigned +x;另外,還有一些數(shù)據(jù)類型是Windows有,而Linux沒有的,像DWORD、HANDLE、LPSTR等等。于是我寫了一個Windows數(shù)據(jù)類型在Linux下進(jìn)行轉(zhuǎn)換的頭文件
<p> #define INVALID_HANDLE_VALUE -1 </p> <p> #define _MAX_PATH 260 /* max. length of full pathname */ </p> <p> #define HANDLE int </p> <p> #define MAX_PATH 260 </p> <p> #define TRUE true </p> <p> #define FALSE false </p> <p> #define __stdcall </p> <p> #define __declspec(x) </p> <p> #define __cdecl </p> <p> #define max(a,b) (((a) > (b)) ? (a) : (b)) </p> <p> #define min(a,b) (((a) < (b)) ? (a) : (b)) </p> <p> typedef int BOOL; </p> <p> typedef unsigned char BYTE; </p> <p> typedef float FLOAT; </p> <p> typedef FLOAT *PFLOAT; </p> <p> typedef char CHAR; </p> <p> typedef unsigned char UCHAR; </p> <p> typedef unsigned char *PUCHAR; </p> <p> typedef short SHORT; </p> <p> typedef unsigned short USHORT; </p> <p> typedef unsigned short *PUSHORT; </p> <p> typedef long LONG; </p> <p> typedef unsigned short WORD; </p> <p> typedef unsigned long DWORD; </p> <p> typedef long long LONGLONG; </p> <p> typedef unsigned long long ULONGLONG; </p> <p> typedef ULONGLONG *PULONGLONG; </p> <p> typedef unsigned long ULONG; </p> <p> typedef int INT; </p> <p> typedef unsigned int UINT; </p> <p> typedef unsigned int *PUINT; </p> <p> typedef void VOID; </p> <p> typedef char *LPSTR; </p> <p> typedef const char *LPCSTR; </p> <p> typedef wchar_t WCHAR; </p> <p> typedef WCHAR *LPWSTR; </p> <p> typedef const WCHAR *LPCWSTR; </p> <p> typedef DWORD *LPDWORD; </p> <p> typedef unsigned long UINT_PTR; </p> <p> typedef UINT_PTR SIZE_T; </p> <p> typedef LONGLONG USN; </p> <p> typedef BYTE BOOLEAN; </p> <p> typedef void *PVOID; </p> <p> typedef struct _FILETIME { </p> <p> DWORD dwLowDateTime; </p> <p> DWORD dwHighDateTime; </p> <p> } FILETIME; </p> <p> typedef union _ULARGE_INTEGER { </p> <p> struct { </p> <p> DWORD LowPart; </p> <p> DWORD HighPart; </p> <p> }; </p> <p> struct { </p> <p> DWORD LowPart; </p> <p> DWORD HighPart; </p> <p> } u; </p> <p> ULONGLONG QuadPart; </p> <p> } ULARGE_INTEGER, </p> <p> *PULARGE_INTEGER; </p>