diff options
author | Igor Zhukov <fsb4000@yandex.ru> | 2024-08-19 10:39:37 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-19 06:39:37 +0300 |
commit | c19cfee61e136effb05a7fc8a037b0db3b13bd4c (patch) | |
tree | ebd85932ceba880a81483b82faa7b85887d1c652 | |
parent | 6126d2a2052bb48d3472ac0468ade50397d393c5 (diff) | |
download | google-benchmark-c19cfee61e136effb05a7fc8a037b0db3b13bd4c.tar.gz google-benchmark-c19cfee61e136effb05a7fc8a037b0db3b13bd4c.zip |
Fix C4459: Rename a function parameter `profiler_manager` to avoid hiding the global declaration. (#1839)
* Fix C4459: Rename a function parameter `profiler_manager` to avoid hiding the global declaration.
* Treat warnings as errors for MSVC
* disable one warning for MSVC
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | include/benchmark/benchmark.h | 8 | ||||
-rw-r--r-- | src/benchmark_runner.cc | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 40ff758..e0cd696 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,10 @@ if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") add_definitions(-D_CRT_SECURE_NO_WARNINGS) + if(BENCHMARK_ENABLE_WERROR) + add_cxx_compiler_flag(-WX) + endif() + if (NOT BENCHMARK_ENABLE_EXCEPTIONS) add_cxx_compiler_flag(-EHs-) add_cxx_compiler_flag(-EHa-) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 66f3486..53a2224 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -796,6 +796,11 @@ 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 { @@ -1063,6 +1068,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); diff --git a/src/benchmark_runner.cc b/src/benchmark_runner.cc index a380939..c658d57 100644 --- a/src/benchmark_runner.cc +++ b/src/benchmark_runner.cc @@ -126,14 +126,14 @@ BenchmarkReporter::Run CreateRunReport( void RunInThread(const BenchmarkInstance* b, IterationCount iters, int thread_id, ThreadManager* manager, PerfCountersMeasurement* perf_counters_measurement, - ProfilerManager* profiler_manager) { + ProfilerManager* profiler_manager_) { internal::ThreadTimer timer( b->measure_process_cpu_time() ? internal::ThreadTimer::CreateProcessCpuTime() : internal::ThreadTimer::Create()); State st = b->Run(iters, thread_id, &timer, manager, - perf_counters_measurement, profiler_manager); + perf_counters_measurement, profiler_manager_); BM_CHECK(st.skipped() || st.iterations() >= st.max_iterations) << "Benchmark returned before State::KeepRunning() returned false!"; { |