restore BENCHMARK_MAIN() (#1357)

This commit is contained in:
Sergiu Deitsch 2022-02-26 11:17:13 +01:00 committed by GitHub
parent 7cb2914292
commit e33986a000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -1464,7 +1464,15 @@ class Fixture : public internal::Benchmark {
#endif #endif
// Helper macro to create a main routine in a test that runs the benchmarks // 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 // Benchmark Reporters

View File

@ -14,14 +14,5 @@
#include "benchmark/benchmark.h" #include "benchmark/benchmark.h"
BENCHMARK_EXPORT int main(int, char**);
BENCHMARK_MAIN(); 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;
}