Oracle® Developer Studio 12.5:C 用户指南

退出打印视图

更新时间: 2016 年 7 月
 
 

3.1 原子 C 类型的大小和对齐

下表显示了原子数据类型及其表示方法。 对齐(align 列)以字节为单位。

表 7  原子 C 类型的大小和对齐
C 类型
LP64 (AMD64) 大小
LP64 (AMD64) 对齐
ILP32 (i386) 大小
ILP32 (i386) 对齐
LP64 (v9) 大小
LP64 (v9) 对齐
ILP32 (SPARC) 大小
ILP32 (SPARC) 对齐
整型
_Atomic _Bool
1
1
1
1
1
1
1
1
_Atomic char
_Atomic signed char
1
1
1
1
1
1
1
1
_Atomic unsigned char
1
1
1
1
1
1
1
1
_Atomic short
_Atomic signed short
2
2
2
2
2
2
2
2
_Atomic unsigned short
2
2
2
2
2
2
2
2
_Atomic int
_Atomic signed int
_Atomic enum
4
4
4
4
4
4
4
4
_Atomic unsigned int
4
4
4
4
4
4
4
4
_Atomic long
_Atomic signed long
_Atomic unsigned long
8
8
4
4
8
8
4
4
_Atomic long long
_Atomic signed long long
_Atomic unsigned long long
8
8
8
8
8
8
8
8
指针
any-type _Atomic *
_Atomic( any-type (*) () )
8
8
4
4
8
8
4
4
浮点
_Atomic float
4
4
4
4
4
4
4
4
_Atomic double
8
8
8
8
8
8
8
8
_Atomic long double
16
16
12
4
16
16
16
8
复数
_Atomic float _Complex
8
8
8
8
8
8
8
8
_Atomic double _Complex
16
16
16
16
16
16
16
8
_Atomic long double _Complex
32
16
24
4
32
16
32
8
虚数
_Atomic float _Imaginary
4
4
4
4
4
4
4
4
_Atomic double _Imaginary
8
8
8
8
8
8
8
8
_Atomic long double _Imaginary
16
16
12
4
16
16
16
8
结构(有选择性的示例)
_Atomic struct {char a[2];}
2
2
2
2
2
2
2
2
_Atomic struct {short a[2];}
4
4
4
4
4
4
4
4
_Atomic struct {int a[2];}
8
8
8
8
8
8
8
8
_Atomic struct {char a[16];}
16
16
16
16
16
16
16
8

原子 struct 类型的一般对齐规则如下:如果 struct 类型的大小为 2、4、8 或 16 之一,且对应非原子类型的对齐小于该大小,则增大原子 struct 类型的对齐以便与该大小匹配。

位字段不允许原子类型。