From e33986a000987387c92ad29590a88fefe12e746b Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Sat, 26 Feb 2022 11:17:13 +0100 Subject: [PATCH] restore BENCHMARK_MAIN() (#1357) --- include/benchmark/benchmark.h | 10 +++++++++- src/benchmark_main.cc | 11 +---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 79698f69..4d6ce4c6 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -1464,7 +1464,15 @@ class Fixture : public internal::Benchmark { #endif // Helper macro to create a main routine in a test that runs the benchmarks -#define BENCHMARK_MAIN() BENCHMARK_EXPORT int main(int argc, char** argv) +#define BENCHMARK_MAIN() \ + int main(int argc, char** argv) { \ + ::benchmark::Initialize(&argc, argv); \ + if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; \ + ::benchmark::RunSpecifiedBenchmarks(); \ + ::benchmark::Shutdown(); \ + return 0; \ + } \ + int main(int, char**) // ------------------------------------------------------ // Benchmark Reporters diff --git a/src/benchmark_main.cc b/src/benchmark_main.cc index 9b2c47a3..cd61cd2a 100644 --- a/src/benchmark_main.cc +++ b/src/benchmark_main.cc @@ -14,14 +14,5 @@ #include "benchmark/benchmark.h" +BENCHMARK_EXPORT int main(int, char**); BENCHMARK_MAIN(); - -// MSVC does not allow the definition of dllimport. Thus, define it here instead -// inline in a macro. -int main(int argc, char** argv) { - ::benchmark::Initialize(&argc, argv); - if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; - ::benchmark::RunSpecifiedBenchmarks(); - ::benchmark::Shutdown(); - return 0; -}