-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.13.3
Problem description
The most recent release uses , ##__VA_ARGS__
in common.h
. This is not technically in the standard (see e.g. here), but most compilers support it. Clang, however, complains about its use when setting -Wpedantic
. I can work around this by either not passing -Wpedantic
, or passing -Wno-gnu-zero-variadic-macro-arguments
, but I'd rather not do that if it can at all be avoided.
Consider the attached example, test.cpp
. Compiling it with
clang -Wall -Wextra -Wpedantic -Werror -shared -std=c++20 -fPIC $(python -m pybind11 --includes) test.cpp -o test.so
produces the following:
In file included from test.cpp:1:
In file included from .venv/lib/python3.11/site-packages/pybind11/include/pybind11/pybind11.h:13:
In file included from .venv/lib/python3.11/site-packages/pybind11/include/pybind11/detail/class.h:12:
In file included from .venv/lib/python3.11/site-packages/pybind11/include/pybind11/attr.h:13:
.venv/lib/python3.11/site-packages/pybind11/include/pybind11/detail/common.h:493:57: error: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
&PYBIND11_CONCAT(pybind11_module_def_, name),
\
^
1 error generated.
It concerns the following code snippet:
pybind11/include/pybind11/detail/common.h
Lines 493 to 494 in fc97cc4
&PYBIND11_CONCAT(pybind11_module_def_, name), \ | |
##__VA_ARGS__); \ |
I am not sure if pybind needs to consider this a bug or even an issue. But the previous versions of pybind (2.12 and below) worked without a hitch when setting the -Wpedantic
option, so I figured I'd let you know about this here.
Reproducible example code
#include <pybind11/pybind11.h>
int test()
{
return 42;
}
PYBIND11_MODULE(module, m)
{
m.def("test", &test);
}
Is this a regression? Put the last known working version here if it is.
2.12.0