This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -std=c90 -pedantic-errors and <stdint.h>


On 01/06/17 12:54, Vincent Lefevre wrote:
> On 2017-05-31 09:00:21 +0800, Xi Ruoyao wrote:
>> On 2017-05-31 01:11 +0200, Vincent Lefevre wrote:
>>> However, GCC knows about standard headers, so that it could
>>> blacklist <stdint.h> as a special case.
>>>
>> I don't think so...  We can't blacklist a header just because it is
>> named stdint.h.  That's a worse behaviour which is not portable.
>>
>> There are many headers "not portable" in the environment.
>> For example, linux/random.h, bits/stdc++.h and emmintrin.h.
>> Should we blacklist them all with -std=c90 -pedantic-errors?
> 
> More than "not portable", they are non-standard. So, they could just
> be regarded as user code (with a dependency on them). So, there are
> no reasons to blacklist them. <stdint.h> is different because it is
> standard in C99+, even in free-standing implementations. Thus it
> cannot be user code (possible except for old, no longer maintained
> software supporting C90 *only*, but in that case, -pedantic-errors
> wouldn't be used).

I've not used pedantic, so I can't speak with experience here about how
it works in practise, and so what I'm about to write may be complete
rubbish.

I also have no experience at all with how GCC goes about deciding what
to do or what it will generally consider reasonable.  I'm not a compiler
writer.  So what I'm about to write may be complete rubbish twice over :-)

So, I may be completely wrong, but I can see basically two cases where
this header file name conflict occurs;

1. by accident

2. intentionally (perhaps emulating the later standard header files, to
make moving up to a later version easier)

I expect there is nothing anywhere which states using header names which
will be part of a *later* standard is *wrong*, in which case this cannot
be an error.  I can also see a use case where this behaviour is *normal*
and is helpful to the user.

However, I can certainly imagine users wanting to be informed of the
situation if they did *not* intend it - they did not intend to use a
name which conflicts with later versions of the standard - and if the
user is compiling with pedantic, it feels like he is specifically asking
to be informed of such things.

Can we perhaps say that there should normally be no warning or error,
since we can see there *is* a normal use case where this behaviour is
intended as is useful, but that in pedantic mode, there is at least a
warning here, since we are specifying an earlier version of C, but using
a header file name which will conflict with a later version of C.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]