c99标准和c11有什么区别

爱已习惯 1个月前 已收到1个回答 举报

爱情罘爽 3星

共回答了378个问题采纳率:98.6% 评论

C11相比C99的变化

1.对齐处理操作符 alignof,函数 aligned_alloc(),以及 头文件 <stdalign.h>。

2. _Noreturn 函数标记,类似于  gcc 的 __attribute__((noreturn))。

3._Generic 关键词,有点儿类似于 gcc 的 typeof。

4.静态断言( static assertions),_Static_assert(),在解释 #if 和 #error 之后被处理。

5. 删除了 gets() 函数,C99中已经将此函数被标记为过时,推荐新的替代函数 gets_s()。

6. 新的 fopen() 模式,(“…x”)。类似 POSIX 中的 O_CREAT|O_EXCL,在文件锁中比较常用。

7. 匿名结构体/联合体,这个早已经在 gcc 中了,我们并不陌生,定义在 6.7.2.1 p13。

8. 多线程支持,包括:_Thread_local,头文件 <threads.h>,里面包含线程的创建和管理函数(比如 thrd_create(),thrd_exit()),mutex 等等。

9. _Atomic类型修饰符和 头文件 <stdatomic.h>。

10. 带边界检查(Bounds-checking)的函数接口,定义了新的安全的函数。更多参考 Annex K。

11. 改进的  Unicode 支持,新的头文件 <uchar.h> 等。

12. 新增 quick_exit() 函数,作为第三种终止程序的方式,当 exit() 失败时可以做最少的清理工作(deinitializition)。

13. 创建复数的宏, CMPLX()。

14. 更多浮点数处理的宏 (More macros for querying the characteristics of floating point types, concerning subnormal floating point numbers and the number of decimal digits the type is able to store)。

15. struct timespec 成为 time.h 的一部分,以及宏 TIME_UTC,函数 timespec_get()。

2小时前

44
可能相似的问题

猜你喜欢的问题

热门问题推荐

Copyright © 2024 微短问答 All rights reserved. 粤ICP备2021119249号 站务邮箱 service@wdace.com