avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #41689] static_assert


From: anonymous
Subject: [avr-libc-dev] [bug #41689] static_assert
Date: Wed, 11 Mar 2015 16:22:58 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.5.0

Follow-up Comment #1, bug #41689 (project avr-libc):

_Static_assert may be ugly, but it's what ISO C mandates:

http://en.cppreference.com/w/c/language/_Static_assert

static_assert is syntactic sugar imported by <assert.h>.

With gcc, here is a bit of confusion on which is defined when. gcc 4.6
supports _Static_assert, but assert.h has static_assert only when std==c11. In
gcc 4.7, static_assert is defined by assert.h even if std!==c11 (apparently).

I use the following chunk of code to get as much as is available:

#if (__STDC_VERSION__ >= 201112L)
#include <assert.h>
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define static_assert(condition, message) _Static_assert(condition, message)
#else
#define static_assert(condition, message)
#endif

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?41689>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]