不同平台下C\C++數值數據類型長度如下:
類型 win32 win64 linux32 linux64
其中long類型和指針類型需要特別注意,編寫跨平台的軟件時盡量不要使用long類型,或者需要對long類型做特殊處理
---------------------
由上圖可以說明, long在linux下64位與win64位下表現不一致。這可能會導致一些精度問題,需注意。
推薦使用std一套有關整形的申明, 詳細請參閱stdint.h
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
---------------------