From 45a71324b17132d8cc01320b59eb87e3e9170968 Mon Sep 17 00:00:00 2001 From: Liu Zixian Date: Fri, 21 Nov 2025 16:54:24 +0800 Subject: [PATCH] Fix build with gcc-4.x(#5901) Signed-off-by: Liu Zixian --- include/pybind11/conduit/pybind11_platform_abi_id.h | 2 ++ include/pybind11/detail/common.h | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h index d21fdc56d8..c1a2edb8f3 100644 --- a/include/pybind11/conduit/pybind11_platform_abi_id.h +++ b/include/pybind11/conduit/pybind11_platform_abi_id.h @@ -71,6 +71,8 @@ # define PYBIND11_BUILD_ABI \ "_libstdcpp_gxx_abi_1xxx_use_cxx11_abi_" PYBIND11_PLATFORM_ABI_ID_TOSTRING( \ _GLIBCXX_USE_CXX11_ABI) +# elif defined(__GNUC__) && (__GNUC__ < 5) +# define PYBIND11_BUILD_ABI "_gcc_4.x" # else # error "Unknown platform or compiler: PLEASE REVISE THIS CODE." # endif diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 05d6755896..f7cc109d67 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -209,9 +209,10 @@ # define PYBIND11_HAS_VARIANT 1 #endif -#if defined(PYBIND11_CPP17) \ - && ((defined(__has_include) && __has_include()) || defined(_MSC_VER)) -# define PYBIND11_HAS_STRING_VIEW 1 +#if defined(PYBIND11_CPP17) +# if (defined(__has_include) && __has_include()) || defined(_MSC_VER) +# define PYBIND11_HAS_STRING_VIEW 1 +# endif #endif #if (defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)