C++变量长度

 

 

windows

Vc6

(32bit)

Windows

Vc2005

(32bit)

Redhat linux

Gcc 3.2.3

32bit

Redhat linux

Gcc 3.4.6

64bit

Char

1

1

1

1

Unsigned char

1

1

1

1

Char c[12]

12

12

12

12

Const char*

4

4

4

8

Short

2

2

2

2

Unsigned short

2

2

2

2

Int

4

4

4

4

Unsigned int

4

4

4

4

Long

4

4

4

8

Unsigned Long

4

4

4

8

String

16

32

4

8

Vector<string>

16

20

12

24

Vector<int>

16

20

12

24

Vector<short>

16

20

12

24

List<string>

12

24

4

16

List<int>

12

24

4

16

Map<string,int>

16

28

12

48

Map<int,int>

16

28

12

48

Map<short,string>

16

28

12

48

 

WINDOWS

VC6 32位

char: 1
unsigned char: 1
char c[12]: 12
const char*: 4
short: 2
unsigned short: 2
int: 4
unsigned int: 4
long: 4
unsigned long: 4
string: 16
vector<string>: 16
vector<int>: 16
vector<short>: 16
list<string>: 12
list<int>: 12
list<short>: 12
map<string,int>: 16
map<int,int>: 16
map<short,string>: 16

 

WINDOWS

VC2005 32位

char: 1
unsigned char: 1
char c[12]: 12
const char*: 4
short: 2
unsigned short: 2
int: 4
unsigned int: 4
long: 4
unsigned long: 4
string: 32
vector<string>: 20
vector<int>: 20
vector<short>: 20
list<string>: 24
list<int>: 24
list<short>: 24
map<string,int>: 28
map<int,int>: 28
map<short,string>: 28

 

 

linux 32位 redhat

gcc:3.2.3 20030502 (Red Hat Linux 3.2.3-47)

char: 1
unsigned char: 1
char c[12]: 12
const char*: 4
short: 2
unsigned short: 2
int: 4
unsigned int: 4
long: 4
unsigned long: 4
string: 4
vector<string>: 12
vector<int>: 12
vector<short>: 12
list<string>: 4
list<int>: 4
list<short>: 4
map<string,int>: 12
map<int,int>: 12
map<short,string>: 12

 

linux 64位 redhat

gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)

char: 1
unsigned char: 1
char c[12]: 12
const char*: 8
short: 2
unsigned short: 2
int: 4
unsigned int: 4
long: 8
unsigned long: 8
string: 8
vector<string>: 24
vector<int>: 24
vector<short>: 24
list<string>: 16
list<int>: 16
list<short>: 16
map<string,int>: 48
map<int,int>: 48
map<short,string>: 48

你可能感兴趣的:(C++)