From 33e8b19ea428dde3b748d93bb6a64499936df968 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 8 May 2021 15:27:57 +0300 Subject: [PATCH] mdbx-windows: check `_WIN32_WINNT` definition. Related to https://github.com/erthink/libmdbx/issues/155 Change-Id: I49c294bd0fa055026b742a12a6f6ea9cd805cf02 --- mdbx.h | 7 ++++++- src/osal.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mdbx.h b/mdbx.h index b2f95c8d..c1ffa7a7 100644 --- a/mdbx.h +++ b/mdbx.h @@ -616,7 +616,12 @@ extern LIBMDBX_VERINFO_API const struct MDBX_build_info { * So, if you doubt, just build MDBX as the separate DLL and don't worry. */ #ifndef MDBX_CONFIG_MANUAL_TLS_CALLBACK -#if defined(_WIN32_WINNT_VISTA) && WINVER >= _WIN32_WINNT_VISTA +#ifndef _WIN32_WINNT +#error Non-dll build libmdbx requires target Windows version \ + to be explicitly defined via _WIN32_WINNT for properly \ + handling thread local storage destructors. +#endif +#if _WIN32_WINNT >= 0x0600 /* Windows Vista */ /* As described above mdbx_dll_handler() is NOT needed forWindows Vista * and later. */ #define MDBX_CONFIG_MANUAL_TLS_CALLBACK 0 diff --git a/src/osal.h b/src/osal.h index b7c476f2..8021fb78 100644 --- a/src/osal.h +++ b/src/osal.h @@ -143,6 +143,11 @@ __extern_C key_t ftok(const char *, int); #endif /* SunOS/Solaris */ #if defined(_WIN32) || defined(_WIN64) +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 /* Windows 7 */ +#elif _WIN32_WINNT < 0x0500 +#error At least 'Windows 2000' API is required for libmdbx. +#endif /* _WIN32_WINNT */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif /* WIN32_LEAN_AND_MEAN */