Skip to content

Commit

Permalink
fix: Avoid -Wgnu-zero-variadic-macro-arguments in C++20 on clang
Browse files Browse the repository at this point in the history
  • Loading branch information
J-M0 committed Nov 27, 2024
1 parent e0de75c commit cb56233
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,12 +868,19 @@ struct always_construct_holder {
static constexpr bool value = Value;
};

// Avoid -Wgnu-zero-variadic-macro-arguments in C++20 on clang
#ifdef PYBIND11_CPP20
#define PYBIND11_DECLARE_HOLDER_TYPE_ARGS(...) void __VA_OPT__(,) __VA_ARGS__
#else
#define PYBIND11_DECLARE_HOLDER_TYPE_ARGS(...) void, ##__VA_ARGS__
#endif

/// Create a specialization for custom holder types (silently ignores std::shared_ptr)
#define PYBIND11_DECLARE_HOLDER_TYPE(type, holder_type, ...) \
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) \
namespace detail { \
template <typename type> \
struct always_construct_holder<holder_type> : always_construct_holder<void, ##__VA_ARGS__> { \
struct always_construct_holder<holder_type> : always_construct_holder<PYBIND11_DECLARE_HOLDER_TYPE_ARGS(__VA_ARGS__)> { \
}; \
template <typename type> \
class type_caster<holder_type, enable_if_t<!is_shared_ptr<holder_type>::value>> \
Expand Down

0 comments on commit cb56233

Please sign in to comment.