safe-rules
safe-rules copied to clipboard
C 头文件名不应被视为过时的
问题来自提交 https://github.com/Qihoo360/safe-rules/commit/69bba35f4cef3eb4bc303c60fd161a430ef9adb1 。
C++ 标准中将 C 头文件设为弃用是历史错误,因为大部分 C 头文件并不是待移除的候选。 C++23 更正了这个问题,见 WG21 P2340R1。
现在的推荐应该是
The intended use of these headers is for interoperability only. It is possible that C++ source files need to include one of these headers in order to be valid ISO C. Source files that are not intended to also be valid ISO C should not use any of the C headers.
这些头文件仅有意用于可互操作。 C++ 源文件有可能需要包含这些头文件之一以成为合法的 ISO C。无意同时作为合法的 C 的源文件不应该使用任何这些 C 头文件。
虽然但是,我觉得不使用 C 头文件名 是没问题的,这个兼容在我看来纯属是被迫。
这个要求对应 MISRA C++ 2008 18-0-1,算是车规级标准的硬性要求吧,车载产品如果要过审还是得遵守的,现在我们依据的还是C++11,正在向 C++17 靠拢,这个问题先记下,感谢提醒~