C/C++的long类型在64位Windows和Linux下的长度不同

C++
402 0

long在Windows64位上是4字节,在Linux和MacOS下是8字节。如下表所示

系统位数sizeof long
Windows324
Windows644
Linux324
Linux648
MacOS324
MacOS648

需要跨平台开发时,建议不要使用long类型,而是使用long long,或者int64_tuint64_t

最后更新 2023-02-12
评论 ( 0 )
OωO
隐私评论