Le 18 juin 08 à 18:18, Sourav K. Mandal a écrit :

> On Wed, 2008-06-18 at 17:07 +0200, Quentin Mathé wrote:
>
>> The man page example works for me too.
>
> I realize now that this example doesn't help -- it includes getopt.h,
> rather unistd.h, because it uses long options.  I have attached a
> modified example which uses standard getopt and includes unistd.h.
>
>> 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 agree with you.  "-std=c99" seems to be equivalent to passing
> "-std=gnu99 -ansi", where the "-ansi" restricts to ANSI standard (more
> or less; according to the GCC info page, to be really strict you must
> add "-pedantic").  Same with "-std=c89" and just "-ansi", since
> "-std=gnu89" is the default.

I finally found a glibc manual page that describes all that precisely:  
<http://www.gnu.org/software/libtool/manual/libc/Feature-Test-Macros.html 
 >
I think I now fixed the issue properly by passing -D_POSIX_C_SOURCE=2

Thanks,
Quentin.
_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à