-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
triageNew bug, unverifiedNew bug, unverified
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?
3.1.0(latest)
Problem description
I have engaged in a project which combines qt and python. As is known to all that some old qt projects overuse the macro slots
to define qt slots. And the code in pybind11.h (line 1341 slots[next_slot++] = {Py_mod_exec, reinterpret_cast<void *>(exec_fn)};
) uses the conflicted macro slots
. And msvc failed to compile the code.
I suggest the author to insert #undef slots
and #define slots Q_SLOTS
to avoid slots_array slots;
bug. Or just simply rename the variable slots
like pybind_slots
if you like it.
Reproducible example code
/// Initialize an array of slots based on the supplied exec slot and options.
template <typename... Options>
static slots_array init_slots(int (*exec_fn)(PyObject *), Options &&...options) noexcept {
/* NOTE: slots_array MUST be large enough to hold all possible options. If you add an option
here, you MUST also increase the size of slots_array in the type alias above! */
#undef slots
slots_array slots;
size_t next_slot = 0;
if (exec_fn != nullptr) {
slots[next_slot++] = {Py_mod_exec, reinterpret_cast<void *>(exec_fn)};
}
#ifdef Py_mod_multiple_interpreters
slots[next_slot++] = {Py_mod_multiple_interpreters, multi_interp_slot(options...)};
#endif
if (gil_not_used_option(options...)) {
#if defined(Py_mod_gil) && defined(Py_GIL_DISABLED)
slots[next_slot++] = {Py_mod_gil, Py_MOD_GIL_NOT_USED};
#endif
}
// slots must have a zero end sentinel
slots[next_slot++] = {0, nullptr};
return slots;
#define slots Q_SLOTS
}
Is this a regression? Put the last known working version here if it is.
Not a regression
Metadata
Metadata
Assignees
Labels
triageNew bug, unverifiedNew bug, unverified