The ISO standard requires only that an undefined macro evaluates to zero. So while it then makes sense to make a defined value non-zero, it is not required. A value of 1 would also make sense as a non-zero value since that is the value of a true boolean expression when cast to an integer.
So while it is not 'standard' it is probably the most likely and least perverse implementation. However you shouldn't really advocate the explicit testing of such macros by value since to do so demonstrates distinct lack of care. Such macros should be tested for definition only rather than value.
Note that an expression of the form #if defined FOO
FOO
resolves to #if 0L
if FOO
is undefined and #if 1L
if FOO
is defined, but that is an evaluation of defined FOO
and says nothing about the valuue of FOO
.
The following have well defined behaviour in the case that FOO
is defined but with no explicitly assigned value:
#ifdef FOO
#ifndef FOO
#if defined FOO
#if !defined FOO
#if FOO != 0
#if FOO == 0
That is probably enough options not to advocate:
#if FOO == 1