[Bug 25945] C_ASSERT doesn't fail if given non-constant expression

wine-bugs at winehq.org wine-bugs at winehq.org
Wed Feb 2 10:34:34 CST 2011


--- Comment #2 from Alexander Scott-Johns <alexander.scott.johns+winebug at googlemail.com> 2011-02-02 10:34:34 CST ---
According to the GCC documentation, GCC 2.95 supports array designators and
(rvalue) array literals. And according to the c1x draft, <assert.h> should
define a static_assert macro. So this should work:

  #if defined(static_assert)
  # define C_ASSERT(e) static_assert((e), #e " should be true")
  #elif defined(_MSC_VER)
  # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  # define C_ASSERT(e)  \
               extern void __C_ASSERT__(int [sizeof((char[]){ [-!(e)] = 0 })])

Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.

More information about the wine-bugs mailing list