本文主要是介绍使用long还是uint64_t ?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1. sizeof(long)与sizeof(long long) 是多少字节?
Windows下:(32位和64位)
cout << sizeof(long) << " , " << sizeof(unsigned long long) << endl;
输出:
4, 8
在linux下,(64位)
cout << sizeof(long) << " , " << sizeof(unsigned long long) << endl;
输出:
8, 8
其中linux中types.h定义如下:
#if __WORDSIZE == 64
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
#else
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
#endif
2、uint64_t的打印选项是llu:
windows提示:
printf("uint64: %llu\n", u64);
linux提示:应该是lu
printf("uint64: %lu\n", u64);
这篇关于使用long还是uint64_t ?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!