From: aram DOT nahidipour AT spdg DOT COM (Aram Nahidipour) Subject: Re: Can I use getopt in a simple program with cygwin32 ? 11 Feb 1998 15:07:51 -0800 Message-ID: <199802111534.HAA14633.cygnus.gnu-win32@ozone.spdg.com> To: gnu-win32 AT cygnus DOT com, cmcguinn AT macha DOT ucd DOT ie Cormac, Please be more specific what version and why don't you include you c code also. I tried the following code and it is working fine. my version is cygwin32-b18. ------------------------ C code ---------------------------- #include #include main(int argc, char *argv[]) { extern char *optarg; int c; int inttemp; int fd; char chartmp[256]; int i; char *datafile = "aram.test"; while ((c = getopt(argc, argv, "dhf:")) != -1) switch (c) { case 'f': datafile = strdup(optarg); break; case 'h': printf("\"%s\" Usage:\n", argv[0]); printf("\t-f \n"); printf("\t-d dump the content of the data file\n"); exit(0); default: break; } return 0; } ------------------------------------------------------------------ Regards, Aram > > Hi, > > I have a simple program that is command line driven and calls getopt > within the program, however when i compile it using "gcc file.c" I get > file.c: in function 'main': > file.c:47: 'optarg' undeclared (first use this function) > file.c:47: (Each undeclared identifier is reported only once > file.c:47: for each function it appears in.) > file.c:91: 'optopt' undeclared (first use this function) > > What is going on? The same source code compiles under Linux and HP-UX no > problem... can I not use the optopt and optarg and optind variables that > i would expect the calling of the function getopt to set ??? > > Please e-mail me a reply, as I do not subscribe to the mailing list, but > searched through the archives for an answer..... > > Thanks in advance > Cormac > -- > ------------------------------------------------------------------------------- > Cormac McGuinness e-mail: cmcguinn AT macha DOT ucd DOT ie > cmcg AT frank DOT physics DOT dcu DOT ie > =============================================================================== > Experimental Physics Department, Tel: + 353 1 706 2205 > University College Dublin, Fax: + 353 1 283 7275 > Belfield, Dublin 4, Ireland. > Also: > School of Physical Sciences, Tel: + 353 1 704 5840 > Dublin City University, Fax: + 353 1 704 5384 > Glasnevin, Dublin 9, Ireland > > > - > For help on using this list (especially unsubscribing), send a message to > "gnu-win32-request AT cygnus DOT com" with one line of text: "help". > - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".