This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Using __STDC_VERSION__ macro
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Mason <slash dot tmp at free dot fr>
- Cc: GCC help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 1 Feb 2017 13:52:00 +0000
- Subject: Re: Using __STDC_VERSION__ macro
- Authentication-results: sourceware.org; auth=none
- References: <e1868e6d-8cdb-74ee-83a3-347b6893fb6c@free.fr>
On 1 February 2017 at 13:49, Mason wrote:
> Hello,
>
> https://gcc.gnu.org/gcc-5/porting_to.html states
>
> "Typically, this macro is used as in the following:
>
> #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
> /* ... */
> #else
> # include <stdint.h>
> #endif
> "
>
> I think it is unnecessary to test for the existence of __STDC_VERSION__
> because N1256 6.10.1p4 states
> "all remaining identifiers [...] are replaced with the pp-number 0"
>
> Therefore
> #if __STDC_VERSION__ < 199901L
> would work as expected, even when __STDC_VERSION__ is undefined.
> (As the constant-expression would be false.)
But you'd get a warning with -Wundef