发布时间:2016-4-15 18:25
分类名称:C++
#include <stdio.h>
#include <iostream>using namespace std;
int main()
{
cout << "bool " << sizeof(bool) << endl;cout << "char " << sizeof(char) << endl;
cout << "wchar_t " << sizeof(wchar_t) << endl;
cout << "char16_t " << sizeof(char16_t) << endl;
cout << "char32_t " << sizeof(char32_t) << endl;cout << "short " << sizeof(short) << endl;
cout << "int " << sizeof(int) << endl;
cout << "long " << sizeof(long) << endl;
cout << "long long" << sizeof(long long) << endl;cout << "float " << sizeof(float) << endl;
cout << "double " << sizeof(double) << endl;
cout << "long double " << sizeof(long double) << endl;
return 0;
}
===== Windows x86/x64 =====
bool 1
char 1
wchar_t 2
char16_t 2
char32_t 4
short 2
int 4
long 4
long long 8
float 4
double 8
long double 8===== Linux_x64 =====
bool 1
char 1
wchar_t 4
char16_t 2
char32_t 4
short 2
int 4
long 8
long long 8
float 4
double 8
long double 16===== Linux_x86 =====
bool 1
char 1
wchar_t 4
char16_t 2
char32_t 4
short 2
int 4
long 4
long long 8
float 4
double 8
long double 12==== Mac_x64 ====
bool 1
char 1
wchar_t 4
char16_t 2
char32_t 4
short 2
int 4
long 8
long long 8
float 4
double 8
long double 16