代码:
#include <iostream> #include <cstdio> #include <list> #include <string> #include <cstdint> #include <exception> #define PRINT_SIZE(type) printf("%-17s = %zu,inner type: %s ", "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 0; }
在不同的开发环境中,分别编译出x86程序和x64程序,观察执行结果
环境: Win10_64位 + VS2015_32位
在上面的结果中,除了指针的size不一样之外,其它的内置类型是完全相同的.