8159365: assert is not defined for unit tests
authorehelin
Mon, 13 Jun 2016 13:54:46 +0200
changeset 39395 af07388255fc
parent 39394 044a0eb96215
child 39396 84aae7f2f638
8159365: assert is not defined for unit tests Reviewed-by: jwilhelm, coleenp
hotspot/test/native/unittest.hpp
--- a/hotspot/test/native/unittest.hpp	Mon Jun 13 13:48:37 2016 +0200
+++ b/hotspot/test/native/unittest.hpp	Mon Jun 13 13:54:46 2016 +0200
@@ -27,8 +27,17 @@
 
 #define GTEST_DONT_DEFINE_TEST 1
 #include "gtest/gtest.h"
+
+// gtest/gtest.h includes assert.h which will define the assert macro, but hotspot has its
+// own standards incompatible assert macro that takes two parameters.
+// The workaround is to undef assert and then re-define it. The re-definition
+// must unfortunately be copied since debug.hpp might already have been
+// included and a second include wouldn't work due to the header guards in debug.hpp.
 #ifdef assert
   #undef assert
+  #ifdef vmassert
+    #define assert(p, ...) vmassert(p, __VA_ARGS__)
+  #endif
 #endif
 
 #define CONCAT(a, b) a ## b