Skip to content

BENCHMARK_ENABLE_WERROR=Off should also disable -pedantic-errors#2183

Merged
LebedevRI merged 1 commit intogoogle:mainfrom
ednolan:enolan_pedanticerrors1
Apr 28, 2026
Merged

BENCHMARK_ENABLE_WERROR=Off should also disable -pedantic-errors#2183
LebedevRI merged 1 commit intogoogle:mainfrom
ednolan:enolan_pedanticerrors1

Conversation

@ednolan
Copy link
Copy Markdown
Contributor

@ednolan ednolan commented Apr 27, 2026

Otherwise Clang 22 builds fail with:

/build/_deps/benchmark-src/include/benchmark/benchmark.h:1442:30: error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions]
 1442 | #if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0)
      |                              ^

Otherwise Clang 22 builds fail with:

```
/build/_deps/benchmark-src/include/benchmark/benchmark.h:1442:30: error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions]
 1442 | #if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0)
      |                              ^
```
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 27, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@LebedevRI
Copy link
Copy Markdown
Collaborator

The change itself makes sense, but did you check that it solves the issue you were seeing?
Because that warning should already be silenced regardless:

#if defined(__clang__)
#define BENCHMARK_DISABLE_COUNTER_WARNING \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunknown-warning-option\"") \
_Pragma("GCC diagnostic ignored \"-Wc2y-extensions\"")
#define BENCHMARK_RESTORE_COUNTER_WARNING _Pragma("GCC diagnostic pop")
#else
#define BENCHMARK_DISABLE_COUNTER_WARNING
#define BENCHMARK_RESTORE_COUNTER_WARNING
#endif
BENCHMARK_DISABLE_COUNTER_WARNING
#if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0)
#define BENCHMARK_PRIVATE_UNIQUE_ID __COUNTER__
#else
#define BENCHMARK_PRIVATE_UNIQUE_ID __LINE__
#endif
BENCHMARK_RESTORE_COUNTER_WARNING

@ednolan
Copy link
Copy Markdown
Contributor Author

ednolan commented Apr 28, 2026

You're right: the warning was only not silenced for me because I was testing with version 1.9.2 instead of the latest. (So updating to 1.9.5 solved the problem without needing the CMake change).

I still think the proposed change is useful, though.

Copy link
Copy Markdown
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thank you!

@LebedevRI LebedevRI merged commit ff773f8 into google:main Apr 28, 2026
84 checks passed
@ednolan ednolan deleted the enolan_pedanticerrors1 branch April 28, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants