This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC][PATCH v3] Initial support for C11 Annex K Bounds checking functions
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Roland McGrath <roland at hack dot frob dot com>
- Cc: Paul Eggert <eggert at cs dot ucla dot edu>, Ulrich Bayer <ubayer at sba-research dot org>, <libc-alpha at sourceware dot org>
- Date: Fri, 14 Jun 2013 23:30:48 +0000
- Subject: Re: [RFC][PATCH v3] Initial support for C11 Annex K Bounds checking functions
- References: <51B1B444 dot 8080608 at sba-research dot org> <51B43794 dot 1020300 at cs dot ucla dot edu> <51BAF465 dot 4010203 at sba-research dot org> <51BB406C dot 10903 at cs dot ucla dot edu> <51BB4CC9 dot 8050402 at sba-research dot org> <51BB4F14 dot 9020603 at cs dot ucla dot edu> <20130614224231 dot 9F0E22C077 at topped-with-meat dot com>
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