This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC][PATCH v3] Initial support for C11 Annex K Bounds checking functions


On 15.06.2013 07:54, Paul Eggert wrote:> On 06/14/2013 11:58 AM, Ulrich Bayer wrote:
>> CPP suppresses all warnings from system headers
> 
> Ah, sorry, I'd missed that, so I guess we'll need to use #error
> after all.  Too bad.  How about this instead?

It is admittedly simpler. Thanks! 

Now that you have simplified it, let me complicate it again. :)

One thing still bugging me is the inconsistency with other use-macros that
simply require the user to define a macro for including extra functionality. 
For example, a user has learned to write #define __GNU_SOURCE instead of 
#define __GNU_SOURCE 1 to request GNU extensions. Since the C11 standard 
leaves __STDC_WANT_LIB_EXT1__ values other than 0 and 1 undefined, it would 
make sense to map a simple #define __STDC_WANT_LIB_EXT1__ i.e., a macro 
definition without a version number, to the latest version. (for the time 
being: 1)

So how about the following? It's unfortunately a bit longer but from
a user perspective it's definitely preferable. 

#ifdef __STDC_WANT_LIB_EXT1__ 
#define __DO_EXPAND(VAL)  1 ## VAL
#define __IS_EMPTY_OR_ONE(VAL)   ((__DO_EXPAND(VAL) == 1) || (__DO_EXPAND(VAL) == 11))
#else
#define __DO_EXPAND(VAL) 0
#define __IS_EMPTY_OR_ONE(VAL)   0
#endif

/* Use #define __STDC_WANT_LIB_EXT1__ or #define __STDC_WANT_LIB_EXT1__ 1
 to include Annex K functions.  */
#if (defined __GLIBC_USE_LIB_EXT1 \
     && (__GLIBC_USE_LIB_EXT1 != __IS_EMPTY_OR_ONE(__STDC_WANT_LIB_EXT1__)))
# error "Inconsistent definition of __STDC_WANT_LIB_EXT1__"
#endif
#if __IS_EMPTY_OR_ONE(__STDC_WANT_LIB_EXT1__)
# define __GLIBC_USE_LIB_EXT1 1
#else
# define __GLIBC_USE_LIB_EXT1 0
#endif

#undef __DO_EXPAND
#undef __IS_EMPTY_OR_ONE

#if __GLIBC_USE_LIB_EXT1

/* Annex K functions are declared here. */

#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]