diff --git a/src/bsoncxx/include/bsoncxx/v1/detail/bit.hpp b/src/bsoncxx/include/bsoncxx/v1/detail/bit.hpp index e33738ea06..7a29faa06c 100644 --- a/src/bsoncxx/include/bsoncxx/v1/detail/bit.hpp +++ b/src/bsoncxx/include/bsoncxx/v1/detail/bit.hpp @@ -19,10 +19,10 @@ #include #if defined(__has_include) -#if __has_include() +#if __has_include() && (!defined(_MSVC_LANG) || _MSVC_LANG >= 202002L) // Prioritize using std::endian from C++20. #include -#endif // __has_include() +#endif // __has_include() && (!defined(_MSVC_LANG) || _MSVC_LANG >= 202002L) #elif defined(_WIN32) // Forward-compatibility with STL: https://github.com/microsoft/STL/blob/vs-2019-16.5/stl/inc/bit#L26 #elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__)