From 15db5e5feab7022092bac2d4f48087564561ad90 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 21 Jun 2022 15:19:43 -0700 Subject: [PATCH] Set PYBIND11_TYPE_CASTER_ODR_GUARD_ON automatically. --- include/pybind11/detail/type_caster_base.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 970a0cd9a..9c4cf4741 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -904,7 +904,12 @@ struct polymorphic_type_hook : public polymorphic_type_hook_base {}; PYBIND11_NAMESPACE_BEGIN(detail) -#define PYBIND11_TYPE_CASTER_ODR_GUARD_ON +#if !defined(PYBIND11_TYPE_CASTER_ODR_GUARD_ON) && !defined(PYBIND11_TYPE_CASTER_ODR_GUARD_OFF) \ + && (defined(_MSC_VER) || defined(PYBIND11_CPP20) \ + || (defined(PYBIND11_CPP17) && defined(__clang__))) +# define PYBIND11_TYPE_CASTER_ODR_GUARD_ON +#endif + #ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON namespace {