Using __STDC_VERSION__ macro
Mason
slash.tmp@free.fr
Wed Feb 1 14:14:00 GMT 2017
On 01/02/2017 14:52, Jonathan Wakely wrote:
> 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
Right.
I'm not convinced by the usefulness of -Wundef, though.
I suppose its only use is catching typos such as
#define FOO 42
#if GOO
#endif
which would silently discard the conditional code.
Regards.
More information about the Gcc-help
mailing list