This content has been marked as final. Show 2 replies
getopt() isn't part of ANSI, so I think it's being stripped when you give '-ansi'.
man -s3c getopt says
[here's a little bug in the manpage it seems, the function prototypes don't have the closing ");"]
SYNOPSIS SVID3, XPG3 #include <stdio.h> int getopt(int argc, char * const argv, const char *optstring extern char *optarg; extern int optind, opterr, optopt; POSIX.2, XPG4, SUS, SUSv2, SUSv3 #include <unistd.h> int getopt(int argc, char * const argv, const char *optstring extern char *optarg;
You have to decide which standard you want to code to (see "man standards"). For instance these two should work
gcc -ansi -pedantic -Wall -D_XOPEN_SOURCE=500
gcc -std=c99 -pedantic -Wall -D_XOPEN_SOURCE=600
(Xopen 600, or SUSv3, requires C99).
You may also find that you need -D__EXTENSIONS__