This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
I'm not sure if this is wanted, but for completeness: The SUSv2 function strdup() and SUSv4 function strndup() are only declared if __STRICT_ANSI__ is defined. Attached is a patch to also prototype those functions if _XOPEN_SOURCE is defined appropriately. $ cat xopen-strdup-test.c #include <string.h> int main() { strdup("this"); strndup("this",1); } before patch: $ gcc xopen-strdup-test.c -std=c99 -Werror=implicit-function-declaration xopen-strdup-test.c: In function ‘main’: xopen-strdup-test.c:8:3: error: implicit declaration of function ‘strdup’ xopen-strdup-test.c:9:3: error: implicit declaration of function ‘strndup’ after patch: $ gcc xopen-strdup-test.c -std=c99 -Werror=implicit-function-declaration xopen-strdup-test.c: In function ‘main’: xopen-strdup-test.c:8:3: error: implicit declaration of function ‘strdup’ xopen-strdup-test.c:9:3: error: implicit declaration of function ‘strndup’ $ gcc xopen-strdup-test.c -std=c99 -Werror=implicit-function-declaration -D_XOPEN_SOURCE=500 xopen-strdup-test.c: In function ‘main’: xopen-strdup-test.c:9:3: error: implicit declaration of function ‘strndup’ $ gcc xopen-strdup-test.c -std=c99 -Werror=implicit-function-declaration -D_XOPEN_SOURCE=700 newlib/ChangeLog: 2012-10-22 Jon TURNEY <jon.turney@dronecode.org.uk> * libc/include/string.h (strdup, strndup): Declare if not __STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.
Attachment:
string.h.patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |