[RFC][PATCH v3] Initial support for C11 Annex K Bounds checking functions
Joseph S. Myers
joseph@codesourcery.com
Fri Jun 14 23:30:00 GMT 2013
On Fri, 14 Jun 2013, Roland McGrath wrote:
> > It could be, but it's so short that we can just
> > put it in each of the affected headers.
>
> We have features.h for exactly this sort of thing. It boils everything
> down to simple __USE_* macros so that individual header files only ever use
> "#ifdef __USE_FOO". There is no reason to depart from that now, and every
> reason to continue to avoid #if complexity in individual header files.
As I noted in <http://sourceware.org/ml/libc-alpha/2013-06/msg00136.html>
the semantics of __STDC_WANT_LIB_EXT1__ involve its definition at the time
the headers it affects are included - and not its definition at the time
of inclusion of any other C11 header. This means headers need to check
__STDC_WANT_LIB_EXT1__ rather than a macro from <features.h>.
There are, unfortunately, two different practices for different
__STDC_WANT_* macros in different ISO C extensions, regarding whether
inconsistency in the definition between different #includes needs to be
diagnosed (__STDC_WANT_LIB_EXT1__, __STDC_WANT_LIB_EXT2__,
__STDC_WANT_MATH_SPEC_FUNCS__) or whether there is no diagnostic and the
definition when each header is first included is what's relevant
(__STDC_WANT_DEC_FP__ and proposed __STDC_WANT_IEC_18661_EXT1__,
__STDC_WANT_IEC_18661_EXT2__, __STDC_WANT_IEC_18661_EXT3__) - and
regarding whether the macro is 0/1-valued or undefined/defined. I raised
that inconsistency with WG14 in
<http://www.open-std.org/jtc1/sc22/wg14/13016>. But all these macros are
consistent in that if an extension, say, affects <stdio.h> but not
<setjmp.h>, then
#include <setjmp.h>
#define __STDC_WANT_WHATEVER__ 1
#include <stdio.h>
is a valid way of using the macro to enable the feature in <stdio.h>.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list