[cogl/cogl-1.18] util: simplify _COGL_STATIC_ASSERT definition



commit 8d998b64c9cc57c7af0f717e3b8f936c0d989ee3
Author: Robert Bragg <robert linux intel com>
Date:   Mon Oct 14 17:28:11 2013 +0100

    util: simplify _COGL_STATIC_ASSERT definition
    
    This updates the definition of _COGL_STATIC_ASSERT to just use
    _Static_assert if available or be NOP if not. We no longer worry about
    supporting static assertions with older compilers. This fixes some
    verbose warnings that newer compilers were giving with the old typedef
    based static assertion method.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    (cherry picked from commit 645e3607ea7f210d6dcb9d217204790051de7c82)

 cogl/cogl-util.h |   22 ++--------------------
 1 files changed, 2 insertions(+), 20 deletions(-)
---
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index 9f6bfff..b7f705b 100644
--- a/cogl/cogl-util.h
+++ b/cogl/cogl-util.h
@@ -261,30 +261,12 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
  *
  * Note: Only Gcc >= 4.6 supports the c11 _Static_assert which lets us
  * print a nice message if the compile time assertion fails.
- *
- * Note: this assertion macro can only be used in C code where it is
- * valid to use a typedef. This macro should not be used in headers
- * because we can't guarantee a unique name for the typedef due to
- * the name being based on the line number of the file it's used in.
- *
- * Although we can remove this limitation if the compiler supports
- * _Static_assert we currently choose to maintain the limitation in
- * any case to help ensure we don't accidentally create code that
- * doesn't compile on some toolchains because we forgot about this
- * limitation.
  */
 #ifdef HAVE_STATIC_ASSERT
 #define _COGL_STATIC_ASSERT(EXPRESSION, MESSAGE) \
-  _Static_assert (EXPRESSION, MESSAGE); \
-  _COGL_TYPEDEF_ASSERT(EXPRESSION)
+  _Static_assert (EXPRESSION, MESSAGE);
 #else
-#define _COGL_STATIC_ASSERT(EXPRESSION, MESSAGE) \
-  _COGL_TYPEDEF_ASSERT(EXPRESSION)
-
-/* So that we can safely use _Static_assert() if we want to add
- * assertions to internal headers we define it to a NOP here
- * if it's not supported by the compiler. */
-#define _Static_assert(EXPRESSION, MESSAGE)
+#define _COGL_STATIC_ASSERT(EXPRESSION, MESSAGE)
 #endif
 
 #ifdef HAVE_MEMMEM


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