libnonius / nonius

A C++ micro-benchmarking framework
https://nonius.io
Creative Commons Zero v1.0 Universal
359 stars 47 forks source link

Fix for multiply defined symbols on g++ #73

Closed bitshifter closed 8 years ago

bitshifter commented 8 years ago

I was getting this when including nonius.h++ in multiple cpp files.

CMakeFiles/bench.dir/main.cpp.o: In function `nonius::generate_params(nonius::param_configuration)':
main.cpp:(.text+0x369): multiple definition of `nonius::generate_params(nonius::param_configuration)'
CMakeFiles/bench.dir/bench1.cpp.o:bench1.cpp:(.text+0x369): first defined here

main.cpp:

#define NONIUS_RUNNER
#include <nonius.h++>

bench.cpp:

#include <nonius.h++>

NONIUS_BENCHMARK("to_string(42)", []{
    return std::to_string(42);
})

NONIUS_BENCHMARK("to_string(4.2)", []{
    return std::to_string(4.2);
})
rmartinho commented 8 years ago

Oh damn, I need to add a multiple file scenario to the examples so that a build-breaking change gets noticed. Thanks for the PR.