]> git.sesse.net Git - vlc/commitdiff
Provide static_assert() replacement
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 31 Jan 2012 17:16:17 +0000 (19:16 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 31 Jan 2012 17:16:17 +0000 (19:16 +0200)
configure.ac
include/vlc_fixups.h

index e57d05961a4d92d75a22229a5b753aa6d3f2ed76..dd73d2a17f8f953ed658c9ed44ef2969a9d76940 100644 (file)
@@ -511,6 +511,20 @@ AC_LINK_IFELSE([
             c = NULL;
     ])],[AC_DEFINE([HAVE_VASPRINTF],[1],[Define to 1 if you have asprintf function])],[AC_LIBOBJ([vasprintf])])
 
+dnl C11 static_assert()
+AC_MSG_CHECKING([for static_assert in assert.h])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE([
+#include <assert.h>
+#ifndef static_assert
+# error BOOM!
+#endif
+])], [
+  AC_MSG_RESULT([yes])
+  AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define to 1 if <assert.h> defines static_assert.])
+], [
+  AC_MSG_RESULT([no])
+])
+
 # Windows CE does not have strcoll()
 AC_FUNC_STRCOLL
 
index fbeccd6dd459795763420b31f940b31f775f0eb8..a78750b8dbd027163941d4ba0b1e6abaa5461fcd 100644 (file)
@@ -229,6 +229,11 @@ static inline locale_t newlocale(int mask, const char * locale, locale_t base)
 }
 #endif
 
+#if !defined (HAVE_STATIC_ASSERT)
+# define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
+# define static_assert _Static_assert
+#endif
+
 /* Alignment of critical static data structures */
 #ifdef ATTRIBUTE_ALIGNED_MAX
 #   define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))