Linux下定义Windows常用数据类型
将一个Windows程序移植到Linux上,发现两个操作系统对很多数据类型的命名方式区别很大,比如Windows下对于无符号数据类型一般用U+x的方式,像UINT、UCHAR、ULONG,而Linux上就要中规中矩,都是unsigned +x;另外,还有一些数据类型是Windows有,而Linux没有的,像DWORD、HANDLE、LPSTR等等。于是我写了一个Windows数据类型在Linux下进行转换的头文件
<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>