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; -}