Hi Sourav, Le 17 juin 08 à 13:41, Sourav K. Mandal a écrit :
> On Tue, 2008-06-17 at 07:02 +0200, Quentin Mathé wrote: > >> However I get a warning about getopt() being an implicit function. In >> fact, the function doesn't seem to be declared directly in unistd.h >> as >> expected, and the man page doesn't mention any preprocessor variables >> to define in addition to unistd.h include. If somebody knows where >> the >> problem lies, let me know :-) > > What's your dev platform? Ubuntu 7.10 (Gutsy) > If you're on something weird/old, stdio.h > might have it, or you have to include getopt.h directly. > > On my Gentoo setup with glibc-2.5, unistd.h includes getopt.h > ifdef'd on > a declaration of POSIX v2. GCC uses C extensions that don't conflict > with ANSI C -- I believe POSIX v2 is in this category. The example > program on the man page "just works." The man page example works for me too. After some experiments, I have found the problem comes from passing the flag -std=c99 to GCC. The example fails to compile with it, unless I pass -D_GNU_SOURCE or I use -std=gnu99 instead of c99. I'm not sure why I observe this behavior. I suppose getopt() is a posix extension not part of the C99 standard lib. On Linux (at least Ubuntu), posix extensions are enabled by default except for c99 (and probably other strict ISO C versions). Is my reasoning correct? I think David Chisnall wrote this code for FreeBSD initially. So this point doesn't seem to hold for FreeBSD. Thanks for the help :-) Quentin. _______________________________________________ Etoile-discuss mailing list [email protected] https://mail.gna.org/listinfo/etoile-discuss
