diff --git a/CMakeLists.txt b/CMakeLists.txt index 66cd942d..a811cd80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -440,7 +440,7 @@ if(MDBX_CXX_STANDARD GREATER_EQUAL 11 AND MDBX_CXX_STANDARD LESS 83) option(MDBX_ENABLE_TESTS "Build MDBX tests" ${BUILD_TESTING}) endif() if(NOT MDBX_AVOID_CRT - AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) + AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4) AND NOT (MSVC AND MSVC_VERSION LESS 1900)) option(MDBX_BUILD_CXX "Build C++ portion" ON) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index ded85039..28ee0214 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -773,7 +773,7 @@ if(CMAKE_CXX_COMPILER_LOADED) # determine library for for std::filesystem set(LIBCXX_FILESYSTEM "") if(CMAKE_COMPILER_IS_GNUCXX) - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) set(LIBCXX_FILESYSTEM "stdc++fs") endif() elseif(CMAKE_COMPILER_IS_CLANG) diff --git a/mdbx.h b/mdbx.h index b417a1d6..dfa59fda 100644 --- a/mdbx.h +++ b/mdbx.h @@ -396,8 +396,8 @@ typedef mode_t mdbx_mode_t; #define cxx07_constexpr_var const #elif !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || \ (defined(__LCC__) && __LCC__ < 124) || \ - (defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) && \ - !defined(__LCC__)) || \ + (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \ + !defined(__clang__) && !defined(__LCC__)) || \ (defined(_MSC_VER) && _MSC_VER < 1910) || \ (defined(__clang__) && __clang_major__ < 4) #define cxx07_constexpr inline @@ -1272,7 +1272,7 @@ enum MDBX_txn_flags_t { * will be ready for use with \ref mdbx_txn_renew(). This flag allows to * preallocate memory and assign a reader slot, thus avoiding these operations * at the next start of the transaction. */ -#if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER < 1910 +#if defined(__cplusplus) && !defined(__cpp_constexpr) && !defined(DOXYGEN) MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT), #else MDBX_TXN_RDONLY_PREPARE = MDBX_RDONLY | MDBX_NOMEMINIT, diff --git a/src/internals.h b/src/internals.h index c4dfeec7..e45902d5 100644 --- a/src/internals.h +++ b/src/internals.h @@ -1399,7 +1399,7 @@ ceil_powerof2(size_t value, size_t granularity) { MDBX_LIFORECLAIM | MDBX_EXCLUSIVE) #define ENV_USABLE_FLAGS (ENV_CHANGEABLE_FLAGS | ENV_CHANGELESS_FLAGS) -#if !(defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1900) +#if !defined(__cplusplus) || defined(__cpp_constexpr) static __maybe_unused void static_checks(void) { STATIC_ASSERT_MSG(INT16_MAX - CORE_DBS == MDBX_MAX_DBI, "Oops, MDBX_MAX_DBI or CORE_DBS?"); diff --git a/test/config.cc b/test/config.cc index 1b057397..de0ef51b 100644 --- a/test/config.cc +++ b/test/config.cc @@ -475,14 +475,24 @@ const std::string actor_config::serialize(const char *prefix) const { result.append(params.pathname_log); result.push_back('|'); +#if __cplusplus > 201400 static_assert(std::is_trivially_copyable::value, "actor_params_pod should by POD"); +#else + static_assert(std::is_standard_layout::value, + "actor_params_pod should by POD"); +#endif result.append(data2hex(static_cast(¶ms), sizeof(actor_params_pod), checksum)); result.push_back('|'); +#if __cplusplus > 201400 static_assert(std::is_trivially_copyable::value, "actor_config_pod should by POD"); +#else + static_assert(std::is_standard_layout::value, + "actor_config_pod should by POD"); +#endif result.append(data2hex(static_cast(this), sizeof(actor_config_pod), checksum)); result.push_back('|'); @@ -527,8 +537,13 @@ bool actor_config::deserialize(const char *str, actor_config &config) { TRACE("<< actor_config::deserialize: slash-3\n"); return false; } +#if __cplusplus > 201400 static_assert(std::is_trivially_copyable::value, "actor_params_pod should by POD"); +#else + static_assert(std::is_standard_layout::value, + "actor_params_pod should by POD"); +#endif if (!hex2data(str, slash, static_cast(&config.params), sizeof(actor_params_pod), checksum)) { TRACE("<< actor_config::deserialize: actor_params_pod(%.*s)\n", @@ -542,8 +557,13 @@ bool actor_config::deserialize(const char *str, actor_config &config) { TRACE("<< actor_config::deserialize: slash-4\n"); return false; } +#if __cplusplus > 201400 static_assert(std::is_trivially_copyable::value, "actor_config_pod should by POD"); +#else + static_assert(std::is_standard_layout::value, + "actor_config_pod should by POD"); +#endif if (!hex2data(str, slash, static_cast(&config), sizeof(actor_config_pod), checksum)) { TRACE("<< actor_config::deserialize: actor_config_pod(%.*s)\n", diff --git a/test/keygen.cc b/test/keygen.cc index 04e600a5..b60f8164 100644 --- a/test/keygen.cc +++ b/test/keygen.cc @@ -198,7 +198,7 @@ void __hot maker::pair(serial_t serial, const buffer &key, buffer &value, void maker::setup(const config::actor_params_pod &actor, unsigned actor_id, unsigned thread_number) { -#if !defined(_MSC_VER) || _MSC_VER > 1900 +#if defined(__cpp_constexpr) static_assert(unsigned(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT | MDBX_INTEGERDUP | MDBX_REVERSEDUP) < UINT16_MAX, "WTF?"); @@ -317,7 +317,7 @@ void __hot maker::mk_begin(const serial_t serial, const essentials ¶ms, void __hot maker::mk_continue(const serial_t serial, const essentials ¶ms, result &out) { -#if !defined(_MSC_VER) || _MSC_VER > 1900 +#if defined(__cpp_constexpr) static_assert( (essentials::prng_fill_flag & unsigned(MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERKEY |