This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] support: Define support_static_assert for use from C and C++
- From: Carlos O'Donell <carlos at redhat dot com>
- To: Paul Eggert <eggert at cs dot ucla dot edu>, Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Fri, 5 Jan 2018 10:41:11 -0800
- Subject: Re: [PATCH] support: Define support_static_assert for use from C and C++
- Authentication-results: sourceware.org; auth=none
- References: <20171231192358.7F97E401BC22B@oldenburg.str.redhat.com> <1adc782a-5eb3-a9ed-79af-9304bbe9727c@cs.ucla.edu>
On 12/31/2017 12:25 PM, Paul Eggert wrote:
> Florian Weimer wrote:
>> +/* Static assertion, under a common name for both C++ and C11. */
>> +#ifdef __cplusplus
>> +# define support_static_assert static_assert
>> +#else
>> +# define support_static_assert _Static_assert
>> +#endif
>
> Wouldn't it be simpler to do this?
>
> #ifdef __cplusplus
> # define _Static_assert static_assert
> #endif
>
> and then use _Static_assert everywhere? Or do it the other way
> around. It seems odd to introduce yet another name
> "support_static_assert" for this concept.
This seems like a a bad idea that will eventually bite us.
I do not suggest a define like this, either we use _Static_assert,
or we use static_assert, but not redefine one to the other.
I'm perfectly happy with support_static_assert, it's not confusing
and it's used internally in the support framework anyway, users
writing test cases in C++ just use TEST_COMPARE or _Static_assert
directly.
--
Cheers,
Carlos.