summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-10-14 17:28:11 +0100
committerRobert Bragg <robert@linux.intel.com>2013-10-15 15:06:35 +0100
commit9259ce64735c8babfd3921cb76eaa1f2e57a109d (patch)
treea09628577f1f39b05df841d11a843939fbccace6
parent515aebd575e23aec372300f418fdc2531567371e (diff)
downloadcogl-9259ce64735c8babfd3921cb76eaa1f2e57a109d.tar.gz
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)
-rw-r--r--cogl/cogl-util.h22
1 files changed, 2 insertions, 20 deletions
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index 9f6bfffb..b7f705b9 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