vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Jan 31 
19:16:17 2012 +0200| [351690f6f7dfe062edf94f7f8f9a256ec0d48d1f] | committer: 
Rémi Denis-Courmont

Provide static_assert() replacement

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=351690f6f7dfe062edf94f7f8f9a256ec0d48d1f
---

 configure.ac         |   14 ++++++++++++++
 include/vlc_fixups.h |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index e57d059..dd73d2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
 
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index fbeccd6..a78750b 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -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)))

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to