From 0488f189a43b4957f8307447c1f8bbdc10399ad4 Mon Sep 17 00:00:00 2001 From: James Morris Date: Tue, 26 Nov 2024 20:31:03 -0500 Subject: [PATCH] fix: Avoid -Wgnu-zero-variadic-macro-arguments in C++20 on clang --- include/pybind11/cast.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 2ae25c2ebf..baccbcca46 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -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 \ - struct always_construct_holder : always_construct_holder { \ - }; \ + struct always_construct_holder \ + : always_construct_holder {}; \ template \ class type_caster::value>> \ : public type_caster_holder {}; \