Description of problem: strdup() not declared in string.h contrary to man 3 strdup Version-Release number of selected component (if applicable): glibc-headers-2.3.3-46 gcc35-3.5.0-0.9 gcc-3.4.1-9 How reproducible: 100% Steps to Reproduce: 1. ellson@ontap:~> cat bug.c #include <string.h> int main() { char *a = "abc"; char *b = strdup(a); return (strcmp(a,b)); } ellson@ontap:~> gcc35 -std=c99 bug.c bug.c: In function `main': bug.c:4: warning: implicit declaration of function 'strdup' bug.c:4: warning: initialization makes pointer from integer without a cast ellson@ontap:~> 2. 3. Actual results: warning about implicit declaration Expected results: no warning Additional info:
strdup is not an ISO C99 function, string.h is a ISO C99 header. Therefore when requesting strict ISO C99 namespace strdup can't be visible. Please RTFM info libc about feature set macros. Particularly, e.g. gcc -std=c99 -D_POSIX_C_SOURCE=200112L, -std=c99 -D_GNU_SOURCE (and similarly for other feature sets which include strdup) will provide a strdup prototype.
*** Bug 130819 has been marked as a duplicate of this bug. ***
*** Bug 130825 has been marked as a duplicate of this bug. ***
*** Bug 130829 has been marked as a duplicate of this bug. ***