I have just installed a fresh Visual Studio 16.10.3 and added Google Test
to my command console app. Right of the bat, I get the following warnings:
Severity | Code | Description | Project | File | Line | Suppression State |
---|---|---|---|---|---|---|
Warning | C26812 | The enum type 'testing::TestPartResult::Type' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). | Tests | D:\C++\ConsoleTest\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build\native\include\gtest\gtest-test-part.h | 62 | |
Warning | C26495 | Variable 'testing::internal::Mutex::critical_section_' is uninitialized. Always initialize a member variable (type.6). | Tests | D:\C++\ConsoleTest\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build\native\include\gtest\internal\gtest-port.h | 1804 | |
Warning | C26495 | Variable 'testing::internal::Mutex::critical_section_init_phase_' is uninitialized. Always initialize a member variable (type.6). | Tests | D:\C++\ConsoleTest\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build\native\include\gtest\internal\gtest-port.h | 1804 | |
Warning | C26495 | Variable 'testing::internal::Mutex::owner_thread_id_' is uninitialized. Always initialize a member variable (type.6). | Tests | D:\C++\ConsoleTest\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build\native\include\gtest\internal\gtest-port.h | 1804 | |
Warning | C26495 | Variable 'testing::internal::Mutex::type_' is uninitialized. Always initialize a member variable (type.6). | Tests | D:\C++\ConsoleTest\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build\native\include\gtest\internal\gtest-port.h | 1804 | |
Warning | C26812 | The enum type 'testing::internal::Mutex::StaticConstructorSelector' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). | Tests | D:\C++\ConsoleTest\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build\native\include\gtest\internal\gtest-port.h | 1804 |
I tried suppressing the warnings by surrounding #include "pch.h"
as described here:
#pragma warning(push, 0)
#include "pch.h"
#pragma warning(pop)
However, that didn't work - instead, I only got an additional warning that
#pragma warning(pop): no matching '#pragma warning(push)' (C4193)
I also read the Broken Warnings Theory. Unfortunately, I have to admit that I do not understand it. I think this is the relevant section:
To suppress the warning in external headers, we need to both specify which headers are external and what the warning level in those headers should be:
cl.exe /experimental:external /external:I some_lib_dir /external:W0 /W4 my_prog.cpp
This would effectively get rid of any warning inside some_hdr.hpp while preserving warnings inside my_prog.cpp.
But where would I add these switches and what would be the correct path variable for googletest?
Thank you in advance for your help!