-std=c99 breaks include of getopt, random
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
Invalid
|
Medium
|
Unassigned |
Bug Description
According to getopt(3) and random(3), #include'ing unistd.h and stdlib.h should declare getopt() (and its associated globals) and random() respectively. This appears not to be the case:
[pwb@rhuidean c]$ gcc -std=c99 -o dice dice.c
dice.c: In function ‘usage’:
dice.c:26: error: ‘optopt’ undeclared (first use in this function)
dice.c:26: error: (Each undeclared identifier is reported only once
dice.c:26: error: for each function it appears in.)
dice.c: In function ‘getopts’:
dice.c:45: warning: implicit declaration of function ‘getopt’
dice.c:50: error: ‘optarg’ undeclared (first use in this function)
dice.c: In function ‘main’:
dice.c:86: warning: implicit declaration of function ‘random’
dice.c uses both. This is libc6-dev 2.3.5-1ubuntu12 on Breezy with gcc 4.0.1-3, gcc-4.0 4.0.1-4ubuntu9.
oh and manpages-dev 2.02-2, in case this behaviour is correct.