From bb7df7338a8e4b80b6485c729c5035669860f555 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 19 Aug 2024 09:44:35 +0700 Subject: [PATCH] disable the warning in code, not CMakeLists.txt --- CMakeLists.txt | 4 ---- include/benchmark/benchmark.h | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35acf9b9c..e0cd6962e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,10 +150,6 @@ if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") add_definitions(-D_CRT_SECURE_NO_WARNINGS) - # Disable padding warning because we did it intentionally - # C4324: 'benchmark::State': structure was padded due to alignment specifier - add_cxx_compiler_flag(-wd4324) - if(BENCHMARK_ENABLE_WERROR) add_cxx_compiler_flag(-WX) endif() diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 66f34867d..12b457d46 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -796,9 +796,15 @@ enum Skipped } // namespace internal +#if defined(_MSC_VER) +#pragma warning(push) +// C4324: 'benchmark::State': structure was padded due to alignment specifier +#pragma warning(disable : 4324) +#endif // _MSC_VER_ // State is passed to a running Benchmark and contains state for the // benchmark to use. class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State { + public: struct StateIterator; friend struct StateIterator; @@ -1063,6 +1069,9 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State { friend class internal::BenchmarkInstance; }; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif // _MSC_VER_ inline BENCHMARK_ALWAYS_INLINE bool State::KeepRunning() { return KeepRunningInternal(1, /*is_batch=*/false);