long 在不一樣操做系統下所佔用的字節數

不一樣平臺下C\C++數值數據類型長度以下:linux

類型 win32 win64 linux32 linux64
ui

 

其中long類型和指針類型須要特別注意,編寫跨平臺的軟件時儘可能不要使用long類型,或者須要對long類型作特殊處理
--------------------- spa

由上圖能夠說明, 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;
---------------------

blog

相關文章
相關標籤/搜索