diff --git a/include/boost/json/detail/config.hpp b/include/boost/json/detail/config.hpp index a11cc0561..933c5de2c 100644 --- a/include/boost/json/detail/config.hpp +++ b/include/boost/json/detail/config.hpp @@ -40,11 +40,16 @@ # endif #endif -#ifndef BOOST_JSON_NO_DESTROY -# if defined(__clang__) && defined(__has_cpp_attribute) +#ifndef BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY + // clang, but not clang-cl +# if defined(__clang__) && !defined(_MSC_VER) && defined(__has_cpp_attribute) # if __has_cpp_attribute(clang::no_destroy) -# define BOOST_JSON_NO_DESTROY [[clang::no_destroy]] +# define BOOST_JSON_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]] +# else +# define BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY # endif +# else +# define BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY # endif #endif diff --git a/include/boost/json/detail/default_resource.hpp b/include/boost/json/detail/default_resource.hpp index 08b986225..a5c53948f 100644 --- a/include/boost/json/detail/default_resource.hpp +++ b/include/boost/json/detail/default_resource.hpp @@ -33,12 +33,12 @@ default_resource final union holder; #ifndef BOOST_JSON_WEAK_CONSTINIT -# ifndef BOOST_JSON_NO_DESTROY +# ifdef BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY static holder instance_; -# else - BOOST_JSON_NO_DESTROY +# else // BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY + BOOST_JSON_ATTRIBUTE_NO_DESTROY static default_resource instance_; -# endif +# endif // BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY #endif public: diff --git a/include/boost/json/detail/impl/default_resource.ipp b/include/boost/json/detail/impl/default_resource.ipp index 4eee8304d..6b927c038 100644 --- a/include/boost/json/detail/impl/default_resource.ipp +++ b/include/boost/json/detail/impl/default_resource.ipp @@ -17,15 +17,15 @@ namespace json { namespace detail { #ifndef BOOST_JSON_WEAK_CONSTINIT -# ifndef BOOST_JSON_NO_DESTROY +# ifdef BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY BOOST_JSON_REQUIRE_CONST_INIT default_resource::holder default_resource::instance_; -# else +# else // BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY BOOST_JSON_REQUIRE_CONST_INIT default_resource default_resource::instance_; -# endif +# endif // BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY #endif // this is here so that ~memory_resource