一、x86编译器
1.操作系统内核信息
2.测试代码
#include <iostream>
using namespace std;
int main(int argc,char** argv)
{
cout << "sizeof(char) = " << sizeof(char) << endl;
cout << "sizeof(short) = " << sizeof(short) << endl;
cout << "sizeof(int) = " << sizeof(int) << endl;
cout << "sizeof(long) = " << sizeof(long) << endl;
cout << "sizeof(long long) = " << sizeof(long long) << endl;
cout << "sizeof(float) = " << sizeof(float) << endl;
cout << "sizeof(double) = " << sizeof(double) << endl << endl;
cout << "sizeof(char*) = " << sizeof(char*) << endl;
cout << "sizeof(short*) = " << sizeof(short*) << endl;
cout << "sizeof(int*) = " << sizeof(int*) << endl;
cout << "sizeof(long*) = " << sizeof(long*) << endl;
cout << "sizeof(long long*) = " << sizeof(long long*) << endl;
cout << "sizeof(float*) = " << sizeof(float*) << endl;
cout << "sizeof(double*) = " << sizeof(double*) << endl << endl;
char cmd;
std::cin >> cmd;
return 0;
}
3.运行结果
二、x64编译器
1.操作系统内核信息
2.测试代码
#include <iostream>
using namespace std;
int main(int argc,char** argv)
{
cout << "sizeof(char) = " << sizeof(char) << endl;
cout << "sizeof(short) = " << sizeof(short) << endl;
cout << "sizeof(int) = " << sizeof(int) << endl;
cout << "sizeof(long) = " << sizeof(long) << endl;
cout << "sizeof(long long) = " << sizeof(long long) << endl;
cout << "sizeof(float) = " << sizeof(float) << endl;
cout << "sizeof(double) = " << sizeof(double) << endl << endl;
cout << "sizeof(char*) = " << sizeof(char*) << endl;
cout << "sizeof(short*) = " << sizeof(short*) << endl;
cout << "sizeof(int*) = " << sizeof(int*) << endl;
cout << "sizeof(long*) = " << sizeof(long*) << endl;
cout << "sizeof(long long*) = " << sizeof(long long*) << endl;
cout << "sizeof(float*) = " << sizeof(float*) << endl;
cout << "sizeof(double*) = " << sizeof(double*) << endl << endl;
char cmd;
std::cin >> cmd;
return 0;
}
3.运行结果
三、测试结果分析
对比分析x86和x64编译器环境下,除了sizeof(long) ,以及内存地址的长度不同,其他常用数据类型的长度是一样的。