google / open-vcdiff

An encoder/decoder for the VCDIFF (RFC3284) format
Apache License 2.0
186 stars 52 forks source link

VCD_COMPILE_ASSERT warns with -Wunused-local-typedef #44

Closed Steelskin closed 9 years ago

Steelskin commented 9 years ago

Both gcc and clang warn on unused typedefs in recent versions. VCD_COMPILE_ASSERT triggers this. Please apply this patch to fix this for projects using c++11 (like e.g. chromium):

diff --git a/src/compile_assert.h b/src/compile_assert.h
index 3f4344f..86a1269 100644
--- a/src/compile_assert.h
+++ b/src/compile_assert.h
@@ -46,9 +46,13 @@ struct CompileAssert {

 }  // namespace open_vcdiff

+#if __cplusplus >= 201103L
+#define VCD_COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
+#else
 #define VCD_COMPILE_ASSERT(expr, msg) \
   typedef open_vcdiff::CompileAssert<static_cast<bool>(expr)> \
       msg[static_cast<bool>(expr) ? 1 : -1]
+#endif

 // Implementation details of VCD_COMPILE_ASSERT:
 //