Skip to content

Commit d76681c

Browse files
committed
work around clang warn/error on __COUNTER__
- fix #186 - code generated by Cursor and reviewed by @orbeckst - note: vendored googlebench contains __COUNTER__ that is classified by clang as a C2y extension and -Werror and -pedantic-errors makes this fail (even though it is actually supported). This is fixed (worked around) in upstream googlebench but other things changed there and would possibly require some rewriting here. Instead, we opted to just remove -Werror -pedantic-error around the googlebench code.
1 parent cc9fd07 commit d76681c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

libdistopia/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,23 @@ endif()
3434
if(DISTOPIA_BUILD_TESTS)
3535

3636
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Enable googlebench tests" FORCE)
37+
# Newer Clang warns on __COUNTER__ in #if (C2y extension); googlebench uses -Werror.
38+
set(BENCHMARK_ENABLE_WERROR OFF CACHE BOOL "Build googlebench without -Werror" FORCE)
3739
add_subdirectory("googlebench")
40+
# Clang 17+ warns on __COUNTER__ in #if (C2y); -pedantic-errors still makes it fatal for googlebench.
41+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
42+
target_compile_options(benchmark PRIVATE -Wno-c2y-extensions)
43+
target_compile_options(benchmark_main PRIVATE -Wno-c2y-extensions)
44+
endif()
3845

3946
add_executable(bench)
4047
target_sources(bench PRIVATE "test/bench.cpp")
4148
target_link_libraries(bench PUBLIC benchmark::benchmark)
4249
target_link_libraries(bench PUBLIC libdistopia)
4350
target_include_directories(bench PUBLIC ${CMAKE_CURRENT_LIST_DIR})
51+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
52+
target_compile_options(bench PRIVATE -Wno-c2y-extensions)
53+
endif()
4454

4555

4656

0 commit comments

Comments
 (0)