I encountered static_assert when trying to build an optional part of a newer version of Mesa with clang.
Definition taken from FreeBSD. Index: sys/sys/cdefs.h =================================================================== RCS file: /cvs/src/sys/sys/cdefs.h,v retrieving revision 1.39 diff -u -p -r1.39 cdefs.h --- sys/sys/cdefs.h 18 Apr 2014 11:51:17 -0000 1.39 +++ sys/sys/cdefs.h 16 Oct 2016 14:39:41 -0000 @@ -386,6 +386,15 @@ #endif /* + * __STDC_VERSION__ overrides any of the other macros since + * they are non-exclusive. + */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 +# undef __ISO_C_VISIBLE +# define __ISO_C_VISIBLE 2011 +#endif + +/* * Finally deal with BSD-specific interfaces that are not covered * by any standards. We expose these when none of the POSIX or XPG * macros is defined or if the user explicitly asks for them. Index: include/assert.h =================================================================== RCS file: /cvs/src/include/assert.h,v retrieving revision 1.13 diff -u -p -r1.13 assert.h --- include/assert.h 26 Jun 2011 21:11:41 -0000 1.13 +++ include/assert.h 16 Oct 2016 14:05:24 -0000 @@ -61,6 +61,20 @@ #ifndef _ASSERT_H_ #define _ASSERT_H_ + +/* + * Static assertions. In principle we could define static_assert for + * C++ older than C++11, but this breaks if _Static_assert is + * implemented as a macro. + * + * C++ template parameters may contain commas, even if not enclosed in + * parentheses, causing the _Static_assert macro to be invoked with more + * than two parameters. + */ +#if __ISO_C_VISIBLE >= 2011 && !defined(__cplusplus) +#define static_assert _Static_assert +#endif + __BEGIN_DECLS __dead void __assert(const char *, int, const char *); __dead void __assert2(const char *, int, const char *, const char *);
