Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 159563 - gcc with -std=c99 option fails to find some function in "unistd.h"
Summary: gcc with -std=c99 option fails to find some function in "unistd.h"
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 3
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2005-06-04 10:08 UTC by Jianqin Qu
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-06-04 10:27:24 UTC

Attachments (Terms of Use)

Description Jianqin Qu 2005-06-04 10:08:54 UTC
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 10:27:24 UTC
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.