说明符 + 限定符linux
signed char 有符号字符 unsigned char 无符号字符 char 字符(能够是 signed char 或 unsigned char,由实现定义) // 除此以外,还定义了宽字符(c11): 1. wchar_t 2. char16_t 3. char32_t
1. 短整形缓存
short signed short short int signed short int // 等价于 short int
2. 无符号短整形多线程
unsigned short unsigned short int // 等价于 unsigned short int
3. 整形并发
signed int signed int // 等价于 int
4. 无符号整形atom
unsigned unsigned int // 等价于 unsigned int
5. 长整型线程
long long int signed long signed long int // 等价于 long int
6. 无符号长整型unix
unsigned long unsigned long int // 等价于 unsigned long int
7. long long int(c99,不懂该怎么称呼了...)指针
long long long long int signed long long signed long long int // 等价于 long long int
8. unsigned long long int(c99)rest
unsigned long long unsigned long long int // 等价于 unsigned long long int
数据模型code
每种实现对数据类型的大小选择统称为 数据模型,如下四种是你们广泛接受的数据模型:
32 System
1. LP32 2/4/4,(int 16bit,long & pointer 32bit) 1. 仅出如今 win16 API 中 2. LP32 4/4/4,(int,long,pointer 32bit) 1. win32 API 2. 类 unix 系统(linux or mac)
64 System
3. LP64 4/4/8,(int & long 32big,pointer 64 bit) 4. LP64 4/8/8,(int 32 bit,long & pointer 64 bit)
其余模型很是罕见(几乎能够不用理会,实际就是无需理会)!举一个例子,数据模型 LP64 8/8/8(int & long & pointer 64 bit),这种数据模型只出如今早期的 unix 机器上
1. float 单精度浮点型 32bit(4byte) 2. double 双精度浮点型 64bit(8byte) 3. long double 扩展精密浮点型(须要机器支持) >=64 bit
若是使用了 complex.h
,表示须要用到复杂的浮点数
如下写法都是有效的:
float _complex float complex double _complex double complex long double _complex long double complex float _imaginary float imaginary double _imaginary double imaginary long double _imaginary long double imaginary
支持如下三种写法:
// p 是指向原子 const int 的指针 _Atomic const int * p1; // 同上 const atomic_int * p2; // 同上 const Atomic(int) * p3;
原子类型的对象是惟一不受数据竞争的对象,也就是说,它们能够由两个线程并发地修改,或者由另外一个线程修改。
拥有如下四个相关属性:
1. 写入一致性(write-write-coherence) 2. 读取一致性(read-read-coherence) 3. 读写一致性(read-write-coherence) 4. 写读一致性(write-read-coherence)
具体解释参考官方文档:atomic type
目前的 visual studio
中不支持该类型
// 声明 int_t 是 int 的别名 typedef int int_t // 进阶 // char_t 是 char 的别名 // chart_p 是 char* 的别名 // fp 是 char(*)(void) 的别名 typedef char char_t, *char_p, (*fp)(void)
const
// 常量不可改动 const int a = 10;
volatile
// 提醒计算机: // a 变量可能会实时更新,不能缓存 // 这个通常多用在多线程场景下 volatile int a = 10;
restrict
特殊的常量
INFINITY 无穷 NaN 非数字
若是须要准确的了解到数值的范围,请参阅(页面底部):各类类型对应的数值范围