今早在網上偶然看到一篇文章《32位程式移植到64位平台前的準備工作》,文中介紹了32位平台的程式向64位平台進行移植需要注意的一些事項和操作建議。
自己對於64位平台上各種資料型別分別占用多少位元組,存在一些疑問,所以用c/c++中的sizeof分別在這兩種平台上進行了測試。
執行結果如下:(分別用藍色和紅色標記了兩者的差異)
——————————————————————————
機器平台:x86_64 處理器
作業系統:red hat 4.1.2-14
編譯器: gcc version 4.1.2 20070626
size of char is: 1
size of unsigned char is: 1
size of signed char is: 1
size of int is: 4
size of short is: 2
size of long is: 8
size of long int is: 8
size of signed int is: 4
size of unsigned int is: 4
size of unsigned long int is: 8
size of long long int is: 8
size of unsigned long long is: 8
size of float is: 4
size of double is: 8
size of long double is: 16
size of (void *) is: 8
size of (char *) is: 8
size of (int *) is: 8
size of (long *) is: 8
size of (long long *) is: 8
size of (float *) is: 8
size of (double *) is: 8
——————————————————————————
機器平台: x86_32 處理器
作業系統: windows xp sp2
編譯器: vs2005自帶的c++編譯器
size of char is: 1
size of unsigned char is: 1
size of signed char is: 1
size of int is: 4
size of short is: 2
size of long is: 4
size of long int is: 4
size of signed int is: 4
size of unsigned int is: 4
size of unsigned long int is: 4
size of long long int is: 8
size of unsigned long long is: 8
size of float is: 4
size of double is: 8
size of long double is: 8
size of (void *) is: 4
size of (char *) is: 4
size of (int *) is: 4
size of (long *) is: 4
size of (long long *) is: 4
size of (float *) is: 4
size of (double *) is: 4
32位機和64位機下面各型別sizeof的大小
執行結果如下 分別用藍色和紅色標記了兩者的差異 機器平台 x86 64 處理器 作業系統 red hat 4.1.2 14 編譯器 gcc version 4.1.2 20070626 size of char is 1 size of unsigned char is 1 size of sign...
32位機和64位機下面各型別sizeof的大小
機器平台 x86 64 處理器 作業系統 red hat 4.1.2 14 編譯器 gcc version 4.1.2 20070626 size of char is 1 size of unsigned char is 1 size of signed char is 1 size of int...
32位機和64位機下面各型別sizeof的大小
這種型別的題目出的太多了,還是整理下吧!一 機器平台 x86 64 處理器 作業系統 red hat 4.1.2 14 編譯器 gcc version 4.1.2 20070626 char 1 unsigned char 1 signed char 1 int 4 short 2 long 8 l...