googletest
googletest copied to clipboard
[Bug]: GTEST_IS_THREADSAFE defunct
Describe the issue
GTEST_IS_THREADSAFE could be user #defineed to 0 in order to avoid #include <condition_variable> and #include <mutex>.
This possibility regressed by https://github.com/google/googletest/commit/dc10c3b5e55c1101e7759bdb7bf9790cebbf4ad2.
Patching
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 52215409..bb723683 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -820,7 +820,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif // GTEST_IS_THREADSAFE
-#ifdef GTEST_IS_THREADSAFE
+#if GTEST_IS_THREADSAFE
// Some platforms don't support including these threading related headers.
#include <condition_variable> // NOLINT
#include <mutex> // NOLINT
--
does not suffice anymore due to https://github.com/google/googletest/commit/f503588aeee4629e5673f2d88ddec01c9ed4bd6b.
Steps to reproduce the problem
Compile a source file containing
#define GTEST_IS_THREADSAFE 0
#include <gtest/gtest.h>
with cl.exe /std:c++20 /showIncludes or equivalent and observe that <condition_variable> and <mutex> is included in spite of the guard definition.
What version of GoogleTest are you using?
https://github.com/google/googletest/commit/687c589949eaf8734484491a6882a7fc56aebc12
What operating system and version are you using?
Windows 10.0.19045
What compiler and version are you using?
Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32535 for x64
What build system are you using?
MSBuild version 17.6.3+07e294721 for .NET Framework 17.6.3.22601
Additional context
<condition_variable> and <mutex> are not supported in all but the latest versions of Microsoft C++/CLI.