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 0488f18
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,20 @@ 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>> \
: public type_caster_holder<type, holder_type> {}; \
Expand Down

0 comments on commit 0488f18

Please sign in to comment.