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