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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2017-06-01 13:42:10 +0200, Toebs Douglass wrote:
> So, I may be completely wrong, but I can see basically two cases where
> this header file name conflict occurs;
> 
> 1. by accident

In this case, a warning/error is expected.

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

In this case, there should be a way to disable the corresponding check.

But note that for (2), I would first expect that programs are written
to support both C90 and a later standard, in which case a conflict
should not occur. One could write something like:

#if ...
#include <stdint.h>
#else
#include "our-stdint.h"
#endif

This is more or less what MPFR does with its mpfr-intmax.h, but the
#else case is never tested because <stdint.h> is always detected as
being available, even with -std=c90 -pedantic-errors.

> 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.

Just like there is nothing anywhere which states using string lengths
over the C90 implementation limit (which is ridiculously low) is
wrong. But such strings are rejected by -std=c90 -pedantic-errors
as expected.

> 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.

Yes, this is exactly what I suggested.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux