* The implementation uses both enum and typedef because the typedef alone is
* insufficient; gcc allows arrays to be declared with non-constant expressions
* (even in typedefs, where it makes no sense).
+ *
+ * NOTE: if GCC ever changes so that it ignores unused types altogether, this
+ * assert might not fire! We explicitly mark it as unused because GCC 4.8+
+ * uses -Wunused-local-typedefs as part of -Wall, which means the typedef will
+ * generate a warning.
*/
#define ASSERT_ON_COMPILE(e) \
do { \
enum { AssertOnCompileMisused = ((e) ? 1 : -1) }; \
- typedef char AssertOnCompileFailed[AssertOnCompileMisused]; \
+ UNUSED_TYPE(typedef char AssertOnCompileFailed[AssertOnCompileMisused]); \
} while (0)
* (void *)val, we have (void *)(uintptr_t)val.
* The specific problem case is the Windows ddk compiler
* (as used by the SVGA driver). -- edward
+ *
+ * NOTE: See the comment in vm_assert.h for why we need UNUSED_TYPE in
+ * AtomicAssertOnCompile(), and why we need to be very careful doing so.
*/
#define MAKE_ATOMIC_TYPE(name, size, in, out, cast) \
&& 8 * sizeof (out) == size \
&& 8 * sizeof (cast) == size \
? 1 : -1 }; \
- typedef char AssertOnCompileFailed[AssertOnCompileMisused]; \
+ UNUSED_TYPE(typedef char AssertOnCompileFailed[AssertOnCompileMisused]);\
} \
\
\
# endif
#endif
+#ifndef UNUSED_TYPE
+// XXX _Pragma would better but doesn't always work right now.
+# define UNUSED_TYPE(_parm) UNUSED_PARAM(_parm)
+#endif
+
#ifndef UNUSED_VARIABLE
// XXX is there a better way?
# define UNUSED_VARIABLE(_var) (void)_var