[PATCH] score: Support static_assert and _Static_assert
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Nov 5 08:15:23 UTC 2012
On 11/05/2012 05:01 AM, Ralf Corsepius wrote:
> On 11/04/2012 07:56 PM, Sebastian Huber wrote:
>> ---
>> cpukit/score/include/rtems/score/basedefs.h | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/cpukit/score/include/rtems/score/basedefs.h
>> b/cpukit/score/include/rtems/score/basedefs.h
>> index 1f8660c..8239994 100644
>> --- a/cpukit/score/include/rtems/score/basedefs.h
>> +++ b/cpukit/score/include/rtems/score/basedefs.h
>> @@ -163,8 +163,16 @@
>> #define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE
>> #endif
>>
>> -#define RTEMS_STATIC_ASSERT(cond, msg) \
>> - typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1]
>> +#if __cplusplus >= 201103L
>> + #define RTEMS_STATIC_ASSERT(cond, msg) \
>> + static_assert(cond, # msg)
>> +#elif __STDC_VERSION__ >= 201112L
>> + #define RTEMS_STATIC_ASSERT(cond, msg) \
>> + _Static_assert(cond, # msg)
>> +#else
>> + #define RTEMS_STATIC_ASSERT(cond, msg) \
>> + typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1]
>> +#endif
>>
>> #ifndef ASM
>> #ifdef RTEMS_DEPRECATED_TYPES
>>
>
> This patch longs for an explanation - Which issue/bug are you trying to fix?
This gives better error messages:
error: size of array ‘rtems_static_assert_msg’ is negativ
vs.
error: static assertion failed: "msg"
--
Sebastian Huber, embedded brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the devel
mailing list