diff --git a/mdbx.h++ b/mdbx.h++ index 09d825a0..eb370d9f 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -78,11 +78,34 @@ #include #endif -#if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L -#include +#ifndef MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM +#ifdef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL +#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 1 +#elif defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \ + __cplusplus >= 201703L +#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 0 +#elif (!defined(_MSC_VER) || __cplusplus >= 201403L || \ + (defined(_MSC_VER) && \ + defined(_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING) && \ + __cplusplus >= 201403L)) +#if defined(__cpp_lib_experimental_filesystem) && \ + __cpp_lib_experimental_filesystem >= 201406L +#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 1 #elif defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L && \ __has_include() +#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 1 +#else +#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 0 +#endif +#else +#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 0 +#endif +#endif /* MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM */ + +#if MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM #include +#elif defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L +#include #endif #if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L @@ -388,13 +411,21 @@ template using string = ::std::basic_string, ALLOCATOR>; using filehandle = ::mdbx_filehandle_t; -#if defined(DOXYGEN) || \ +#if MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM +#ifdef _MSC_VER +namespace filesystem = ::std::experimental::filesystem::v1; +#else +namespace filesystem = ::std::experimental::filesystem; +#endif +#define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path +#elif defined(DOXYGEN) || \ (defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \ defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L && \ (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || \ __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) && \ (!defined(__IPHONE_OS_VERSION_MIN_REQUIRED) || \ - __IPHONE_OS_VERSION_MIN_REQUIRED >= 130100)) + __IPHONE_OS_VERSION_MIN_REQUIRED >= 130100)) && \ + (!defined(_MSC_VER) || __cplusplus >= 201703L) namespace filesystem = ::std::filesystem; /// \brief Defined if `mdbx::filesystem::path` is available. /// \details If defined, it is always `mdbx::filesystem::path`, @@ -403,10 +434,6 @@ namespace filesystem = ::std::filesystem; /// Nonetheless `MDBX_STD_FILESYSTEM_PATH` not defined if the `::mdbx::path` /// is fallbacked to c `std::string` or `std::wstring`. #define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path -#elif defined(__cpp_lib_experimental_filesystem) && \ - __cpp_lib_experimental_filesystem >= 201406L -namespace filesystem = ::std::experimental::filesystem; -#define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path #endif /* MDBX_STD_FILESYSTEM_PATH */ #ifdef MDBX_STD_FILESYSTEM_PATH diff --git a/src/mdbx.c++ b/src/mdbx.c++ index f33e6617..7c83aa8b 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -11,10 +11,14 @@ #endif /* MDBX_BUILD_CXX*/ /* Workaround for MSVC' header `extern "C"` vs `std::` redefinition bug */ -#if defined(_MSC_VER) && defined(__SANITIZE_ADDRESS__) && \ - !defined(_DISABLE_VECTOR_ANNOTATION) +#if defined(_MSC_VER) +#if defined(__SANITIZE_ADDRESS__) && !defined(_DISABLE_VECTOR_ANNOTATION) #define _DISABLE_VECTOR_ANNOTATION #endif /* _DISABLE_VECTOR_ANNOTATION */ +#ifndef _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +#endif /* #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING */ +#endif /* _MSC_VER */ #include "../mdbx.h++"