Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 130815 - gcc 3.[45] with -std=c99, strdup() not declared in string.h
gcc 3.[45] with -std=c99, strdup() not declared in string.h
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
: 130819 130825 130829 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2004-08-24 17:54 EDT by John Ellson
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-08-30 02:33:40 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description John Ellson 2004-08-24 17:54:42 EDT
Description of problem:
strdup() not declared in string.h contrary to man 3 strdup

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

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

Actual results:
warning about implicit declaration

Expected results:
no warning

Additional info:
Comment 1 Jakub Jelinek 2004-08-30 02:33:40 EDT
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
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.
Comment 2 Jakub Jelinek 2004-08-30 02:34:59 EDT
*** Bug 130819 has been marked as a duplicate of this bug. ***
Comment 3 Jakub Jelinek 2004-08-30 02:36:40 EDT
*** Bug 130825 has been marked as a duplicate of this bug. ***
Comment 4 Jakub Jelinek 2004-08-30 02:38:00 EDT
*** Bug 130829 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.