c 變數大小測試

2021-05-18 08:03:21 字數 4852 閱讀 2317

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

16

20

12

24

vector

16

20

12

24

vector

16

20

12

24

list

12

24

4

16

list

12

24

4

16

map

16

28

12

48

map

16

28

12

48

map

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: 16

vector: 16

vector: 16

list: 12

list: 12

list: 12

map: 16

map: 16

map: 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: 20

vector: 20

vector: 20

list: 24

list: 24

list: 24

map: 28

map: 28

map: 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: 12

vector: 12

vector: 12

list: 4

list: 4

list: 4

map: 12

map: 12

map: 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: 24

vector: 24

vector: 24

list: 16

list: 16

list: 16

map: 48

map: 48

map: 48

c語言區域性變數與全域性變數大小的限制

注 本文 寫程式時發現了乙個大陣列無法使用區域性變數的問題,必須使用全域性變數,總結時發現了博主這篇很好的文章,收藏!看 include int main 編譯執行後發現溢位錯誤。include int a 1000000 全域性變數 int main 編譯執行後正常。1 棧區 stack segm...

View 測量大小

view 的繪製要經過 measure layout 和 draw 這三個步驟,這篇記錄下測量時的關鍵點。the actual measurement work of a view is performed in called by this method.therefore,only can an...

C C 檢視變數大小和陣列長度

這裡總結一下c c 中檢視變數大小,陣列長度等的方法。本文 在windows 8.1下使用dev c編寫,測試。1 標頭檔案 2 include c 3 或者 4 include c 5 函式原型 6externunsignedintstrlen char s strlen做的是乙個計數器的工作,函...