ISO C 数据表示法
本附录介绍了 ISO C 如何表示存储器中的数据以及向函数传递参数的机制。它可以为想要编写或使用非 C 语言模块并将这些模块与 C 代码连接的程序员提供指导。
G.1 存储分配
下面几个表显示了数据类型及其表示方法。 大小以字节为单位。
注 -
堆栈中分配的存储空间(带有内部、自动或链接的标识符)应限于 2G 字节或更少。
表 100 数据类型的存储分配
|
|
|
|
|
|
整数
|
|
|
|
|
|
_Bool
char
signed char
unsigned char
|
1
|
1
|
1
|
1
|
|
short
signed short
unsigned short
|
2
|
2
|
2
|
2
|
|
int
signed int
unsigned int
enum
|
4
|
4
|
4
|
4
|
|
long
signed long
unsigned long
|
8
|
8
|
4
|
4
|
|
long long
signed long long
unsigned long long
|
8
|
8
|
8
|
4 (x86) / 8 (SPARC)
|
|
指针
|
|
|
|
|
|
any-type *
any-type (*) ()
|
8
|
8
|
4
|
4
|
|
浮点
|
|
|
|
|
|
float
double
long double
|
4
8
16
|
4
8
16
|
4
8
12 (x86) / 16 (SPARC)
|
4
4 (x86) / 8 (SPARC)
4 (x86) / 8 (SPARC)
|
|
复数
|
|
|
|
|
|
float _Complex
double _Complex
long double _Complex
|
8
16
32
|
4
8
16
|
8
16
24 (x86) / 32 (SPARC)
|
4
4 (x86) / 8 (SPARC)
4 (x86) / 8 (SPARC)
|
|
虚数
|
|
|
|
|
|
float _Imaginary
double _Imaginary
long double _Imaginary
|
4
8
16
|
4
8
16
|
4
8
12 (x86) / 16 (SPARC)
|
4
4 (x86) / 8 (SPARC)
4 (x86) / 8 (SPARC)
|
|
原子 C 类型的大小和对齐:
Where T is any of the above types, and struct or union types
size : sizeof(_Atomic(T)) is equal to sizeof(T)
alignment : if size is 1,2,4,8,16 then alignment is equal to the size,
otherwise alignof(_Atomic(T)) is equal to alignof(T)