2013-07-31 62 views
1

我有,即使我定義__STDC_WANT_LIB_EXT1__ 1.支持strerrorlen_s和strerror_s函數的gcc/glibc的最早版本是什麼?

+0

您有什麼麻煩嗎? –

+0

警告:函數'strerrorlen_s'的隱式聲明[-Wimplicit-function-declaration] /tmp/ccNK2h7T.o:函數'main': watchdogd.c :(.text + 0xd7):未定義的引用'strerrorlen_s' collect2:錯誤:ld返回1退出狀態 – clockley1

+0

gcc 4.7.3:cc tc -std = c11 tc:函數'main'中: tc:8:5:警告:函數'strerrorlen_s'的隱式聲明[-Wimplicit函數聲明] /tmp/ccHzZVKk.o:tc:(.text+0x68):未定義的引用'strerrorlen_s' collect2:錯誤:ld返回1退出狀態 –

回答

3

這不是在glib 2.13,至少在Debian下,但我不明白爲什麼這將不同於任何其他系統。在整個磁盤上搜索strerrorlen_s不會返回任何內容。

它也沒有在2.14到目前2.17(搜索boundstr24731strerrorlen_s)的任何發行說明中列出。它甚至沒有在2.18 wiki page上提及。

請記住,在邊界檢查接口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可言。由烏利齊·德雷珀(2012誠然月)上的支持是否會很快到來評論:

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.

0
N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x 

errno_t strerror_s(char *s, rsize_t maxsize, errno_t errnum); 
size_t strerrorlen_s(errno_t errnum); 
size_t strnlen_s(const char *s, size_t maxsize); 

,從我的C11標準的副本的使用strerrorlen_s在GCC 4.7.2麻煩 - N1570草案。也許更高版本的海灣合作委員會有它... 所以我們都不是瘋狂的......

+2

附錄K,規範性附錄K:「本附件規定了一系列**可選**擴展......」。 – paxdiablo

+0

感謝您的發現。 +1 –

相關問題