C++ x86程序与x64程序中,各种内置类型的大小比较
2024-09-04 15:07:12
代码:
#include <iostream>
#include <cstdio>
#include <list>
#include <string>
#include <cstdint>
#include <exception> #define PRINT_SIZE(type) printf("%-17s = %zu,inner type: %s\n", "sizeof("#type")", sizeof(type), typeid(type).name()) void print_sys_bits()
{
#ifdef _WIN64
std::cout << "x64:" << std::endl;
#else
std::cout << "x86:" << std::endl;
#endif
} void print_sizes()
{
PRINT_SIZE(void*);
PRINT_SIZE(float);
PRINT_SIZE(double);
PRINT_SIZE(short);
PRINT_SIZE(int);
PRINT_SIZE(long);
PRINT_SIZE(long long);
PRINT_SIZE(int8_t);
PRINT_SIZE(uint8_t);
PRINT_SIZE(int16_t);
PRINT_SIZE(uint16_t);
PRINT_SIZE(int32_t);
PRINT_SIZE(uint32_t);
PRINT_SIZE(int64_t);
PRINT_SIZE(uint64_t);
} int32_t main()
{
print_sys_bits();
print_sizes();
std::cin.get();
return ;
}
在不同的开发环境中,分别编译出x86程序和x64程序,观察执行结果
环境: Win10_64位 + VS2015_32位
在上面的结果中,除了指针的size不一样之外,其它的内置类型是完全相同的.
最新文章
- UGUI与DOtween的坑
- Urtext的使用
- Mac OS X使用快捷键改善窗口管理的六个方法
- 在命令行中通过adb shell am broadcast发送广播通知
- nginx自学
- java中HashMap的用法
- spring+hibernate--直接修改数据库,再通过hibernate查询数据不变
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 unselect_from_list(self, locator, *items)
- 为什么C/C++语言使用指针
- Maven工程的Web调试
- 在SQL中修改数据库名称
- HashMap 构造函数
- 【Qt编程】Qt学习之窗口间的相互切换
- FFmpeg封装格式处理4-转封装例程
- Jquery ajax 表单.serialize() 和serializeArray()序列化$.param()
- Android 利用二次贝塞尔曲线模仿购物车加入物品抛物线动画
- 排序算法(3)--Insert Sorting--插入排序[3]--Shell Sort--希尔排序
- day 85 Vue学习之vue-cli脚手架下载安装及配置
- python3插入数据
- 网站使用 rel=";noopener"; 打开外部锚