On 04/02/2013 04:16 PM, Paul Berry wrote:
GCC 4.8 now warns about typedefs that are local to a scope and not
used anywhere within that scope. This produces spurious warnings with
the STATIC_ASSERT() macro (which uses a typedef to provoke a compile
error in the event of an assertion failure).
This patch avoids the warning using the GCC __attribute__((unused))
syntax.
---
src/mesa/main/compiler.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index 8b23665..ddeb61d 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -249,6 +249,12 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
#endif
+#if (__GNUC__>= 3)
+#define GCC_ATTRIBUTE_UNUSED __attribute__((unused))
+#else
+#define GCC_ATTRIBUTE_UNUSED
+#endif
+
/**
* Static (compile-time) assertion.
* Basically, use COND to dimension an array. If COND is false/zero the
@@ -256,7 +262,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
*/
#define STATIC_ASSERT(COND) \
do { \
- typedef int static_assertion_failed[(!!(COND))*2-1]; \
+ typedef int static_assertion_failed[(!!(COND))*2-1]
GCC_ATTRIBUTE_UNUSED; \
} while (0)
Without using gcc-isms, I think this would work too:
#define STATIC_ASSERT(COND) \
do { \
int static_assertion_failed[(!!(COND))*2-1]; \
(void) static_assertion_failed; \
} while (0)
I don't recall why I used the typedef.
Also, the same macro should probably be updated in
src/gallium/include/pipe/p_compiler.h
-Brian
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev