benchmark icon indicating copy to clipboard operation
benchmark copied to clipboard

Only enable "-pedantic-errors" when BENCHMARK_ENABLE_WERROR is ON

Open BraynStorm opened this issue 10 months ago • 2 comments

Newer versions of clang (on Windows at least) fail to compile benchmark with -Werror and -pedantic-errors. Unfortunately, the BENCHMARK_ENABLE_WERROR option toggles only -Werror, and not -pedantic-errors.

.../build/Debug/_deps/benchmark-src/src/benchmark.cc:225:7: error: offset of on non-standard-layout type 'State' [-Werror,-Winvalid-offsetof]
   225 |       offsetof(State, skipped_) <= (cache_line_size - sizeof(skipped_)), "");
       |       ^               ~~~~~~~~
 C:\Program Files\LLVM\lib\clang\18\include\__stddef_offsetof.h:11:24: note: expanded from macro 'offsetof'
    11 | #define offsetof(t, d) __builtin_offsetof(t, d)
       |                        ^                     ~
 1 error generated.
 ninja: build stopped: subcommand failed.

This PR changes the CMakeLists.txt file to only append -pedantic-errors when BENCHMARK_ENABLE_WERROR is ON

BraynStorm avatar Mar 30 '24 21:03 BraynStorm