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 159563 - gcc with -std=c99 option fails to find some function in "unistd.h"
gcc with -std=c99 option fails to find some function in "unistd.h"
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2005-06-04 06:08 EDT by Jianqin Qu
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-06-04 06:27:24 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 Jianqin Qu 2005-06-04 06:08:54 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Description of problem:
When you compile the following hello.c file:

#include <unistd.h>
int main(void)
    return 0;

compile it with option:
  gcc -c -std=c99 hello.c
gives the following warning(while it should not):

hello.c: In function `main':
hello.c:8: warning: implicit declaration of function `getdtablesize'

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

How reproducible:

Steps to Reproduce:
1.create a file named hello.c with the above contents
2.compile it with option "-std=c99"

Actual Results:  You got warnings like:

hello.c: In function `main':
hello.c:8: warning: implicit declaration of function `getdtablesize'

Expected Results:  You should not expect any warnings at all.

Additional info:

No. It's very easy to reproduce the bug.
Comment 1 Jakub Jelinek 2005-06-04 06:27:24 EDT
By using -std=c99, you select strict ISO C99 namespace.
getdtablesize is only provided in BSD and X/Open namespaces.
When -std=c99 is not given, the default is BSD and SVID namespace and therefore
getdtablesize has a prototype.
If you want the getdtablesize prototype provided also with -std=c99, you need
to select some namespace that includes it.  So e.g.
-std=c99 -D_GNU_SOURCE
-std=c99 -D_BSD_SOURCE
-std=c99 -D_XOPEN_SOURCE=500
-std=c99 -D_XOPEN_SOURCE=600
depending on which standard your program attempts to conform to.

See info libc on Feature Test Macros.

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