Mail Archives: djgpp/2015/06/06/09:15:09
On 2015-06-05, Eli Zaretskii (eliz AT gnu DOT org) <djgpp AT delorie DOT com> wrote:
>> Date: Thu, 04 Jun 2015 23:15:51 +0300
>> From: "Andris Pavenis (andris DOT pavenis AT iki DOT fi)" <djgpp AT delorie DOT com>
>> #endif /* (__STDC_VERSION__ >= 199901L) || !__STRICT_ANSI__ */
>>
>> -#ifndef __STRICT_ANSI__
>> +#if !defined(__STRICT_ANSI__) || defined(__cplusplus)
>>
>> #define E2BIG 3
>> #define EACCES 4
>
> This looks wrong: we shouldn't have errno values visible under ANSI
> compilation which are not defined by the ANSI C standard. E.g., C99
> only defines EDOM, EILSEQ, and ERANGE.
I do not agree.
The purpose of --ansi (or other C dialect selectors) is to affect the
C dialect used, not the libraries (which are not even part of GCC).
When I use -ansi, I want GCC not to accept nonconforming extensions.
I do not want it to start hiding errno.h constants, or the declaration
of fileno in <stdio.h>.
For hiding/revealing library header features, the implementors should use
feature selection macros (perhaps in conjunction with the dialect selection).
It is reasonable to want to use a standard C dialect, *and* have access to
some platform library features.
> If the later standards define more errno values, they should be only
> visible when the corresponding -std= option was specified for
> compiler.
If that is so, what -std= option should make E2BIG visible?
It's not in any historic or current C standrad.
A reasonable approach:
* In the absence of any dialect option or feature selection macro,
the behavior can be GCC's default dialect, and everything is seen.
* -std=c99 or -ansi hide E2BIG in errno.h, fileno in stdio.h, etc.
* -D_POSIX_SOURCE and other standard POSIX macros reveal what
they are supposed to, regardless of dialect option.
* -D_DJGPP_SOURCE reveals everything in all headers
- Raw text -