long 在不同操作系統下所占用的字節數


不同平台下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;
---------------------


 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM