c - 支持 strerrorlen_s 和 strerror_s 函数的最旧版本的 gcc/glibc 是什么?

标签 c linux glibc c11 tr24731

我在使用 strerrorlen_s 时遇到问题在 gcc 4.7.2 中,即使我定义了 __STDC_WANT_LIB_EXT1__ 1.

最佳答案

它不在 glib 2.13 中,至少在 Debian 下是这样,但我不明白为什么它会与任何其他系统不同。在整个磁盘上搜索 strerrorlen_s 不会返回任何结果。

它也没有在 2.14 到当前 2.17 的任何发行说明中列出(搜索 boundstr24731strerrorlen_s)。 2.18 wiki page 上什至没有提到它.

请记住,边界检查接口(interface)是 C11 的一个可选特性。附件 K 对此进行了详细说明,并且实现根本不需要提供它。

K.2 Scope:

1/ This annex specifies a series of optional extensions that can be useful in the mitigation of security vulnerabilities in programs, and comprise new functions, macros, and types declared or defined in existing standard headers.

2/ An implementation that defines __STDC_LIB_EXT1__ shall conform to the specifications in this annex. Implementations that do not define __STDC_LIB_EXT1__ are not required to conform to these specifications.

看起来实际上根本没有计划在核心 glibc 中支持此功能。来自 Ulrich Drepper(诚然是 2012 年 3 月)关于是否会提供支持的评论:

Even the people who proposed them suggested them for fixing old code and not as the way forward. Such code belong in separate libraries which (a) take effort to use so that the functions become unused and (b) so that the library can be removed when the last offender is gone.

类似地,来自大约同一时间的 LNW 文章:

There are no plans to add the C11 string bounds-checking interfaces from one of the annexes as there are questions about their usefulness even within the standards groups. That doesn't mean that those interfaces couldn't end up in the libc_ports tree, which provides a place for optional add-ons that aren't enabled by default. That would allow distributions or others to build those functions into their version of GLIBC.

关于c - 支持 strerrorlen_s 和 strerror_s 函数的最旧版本的 gcc/glibc 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17960423/

相关文章:

c++ - 是否有任何 c/c++ 编译器可以警告(或给出错误)或枚举转换为 int?

android - 在 Android NDK - C/embed 中映射有关传感器的信号量内存值

c - 函数 srand、rand 和 system 的隐式声明

linux - 从 glibc 源代码生成 libc6-dbg 包

linux - 使用 Yocto SDK 的链接问题(对 `_rtld_global_ro' 的 undefined reference )

计数次数递归被称为C

linux - 如何通过丢帧来加速视频?

linux - Bison 示例代码未编译

linux - 使用 bash 自动安装脚本

c - sscanf 是否修改传递给它的字符串?