stdio.h: broken standard compliance.

Kaz Kylheku
Mon Oct 10 18:43:00 GMT 2011

Corinna Vinschen writes:

> > $ gcc -Wall -ansi -D_POSIX_C_SOURCE=2 posix-ansi.c
> fileno and pclose are *not* ANSI functions. Therefore, if you define
> -ansi, you get the below errors. The newlib headers have explicit
> #ifndef __STRICT_ANSI__ guards around the non-ANSI definitions.

Hi Corinna,

(Could you use "reply all?" for discussions so the original
person is included, but the mailing list is kept in the loop with a 
I had to dig your reply out of the online archives.)

I do not believe that your interpretation of the applicable standards 
entirely correct.

The -ansi flag tells the GNU *compiler* to disable its built-in
extensions. So for instance the block evaluation syntax
({ expr1; ... ; exprn }) won't be available.

The -D_POSIX_C_SOURCE=2 tells the *library headers* to enable
their extensions to a certain revision of POSIX.

With -D_POSIX_SOURCE, programs must see pclose and fileno declared
in <stdio.h>

It is not correct for those headers to be testing GCC's
compliance level  with __STRICT_ANSI__ to determine whether
to reveal these symbols.


Summary of Feature Test Macros in the glibc documentation:

In your Linux manual pages:

  $ man 7 feature_test_macros

In the Single Unix Specification:

Cheers ...

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list