tests: Resolve gtest/xlib conflicts
authorMark Lobodzinski <mark@lunarg.com>
Tue, 27 Mar 2018 23:14:34 +0000 (17:14 -0600)
committerMark Lobodzinski <mark@lunarg.com>
Wed, 28 Mar 2018 17:51:20 +0000 (11:51 -0600)
Gtest and Xlib each redefine 'None' and 'Bool', which causes
gtest compilation to fail hard. Temporarily clear the definitions
to allow gtest to build using an Xlib display server.

Change-Id: I75e53bbff9266a59ebf53a81c2e148e51de6b7c7

tests/test_common.h

index 2e48170d18d341f88df7f6ab857c2dd752f89068..e1d8670c28edde56926d93fbeab390475a0e40cf 100644 (file)
 #pragma warning(disable : 4275)
 #endif
 
+// GTest and Xlib collide due to redefinitions of "None" and "Bool"
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+#pragma push_macro("None")
+#pragma push_macro("Bool")
+#undef None
+#undef Bool
+#endif
+
 // Use the NDK's header on Android
 #ifndef __ANDROID__
-#include "gtest-1.7.0/include/gtest/gtest.h"
-#endif
+#include "../submodules/googletest/googletest/include/gtest/gtest.h"
+#else
 #include "gtest/gtest.h"
+#endif
+
+// Redefine Xlib definitions
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+#pragma pop_macro("Bool")
+#pragma pop_macro("None")
+#endif
 
 #ifdef _WIN32
 #pragma warning(pop)