diff --git a/src/mdbx.c b/src/mdbx.c index e18b6a5b..e1e2df83 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -1325,7 +1325,7 @@ const char *__cold mdbx_strerror_r(int errnum, char *buf, size_t buflen) { if (!msg) { if (!buflen || buflen > INT_MAX) return NULL; -#ifdef _MSC_VER +#if defined(_WIN32) || defined(_WIN64) size_t size = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, (DWORD)buflen, @@ -1354,7 +1354,7 @@ const char *__cold mdbx_strerror_r(int errnum, char *buf, size_t buflen) { const char *__cold mdbx_strerror(int errnum) { const char *msg = __mdbx_strerr(errnum); if (!msg) { -#ifdef _MSC_VER +#if defined(_WIN32) || defined(_WIN64) static char buffer[1024]; size_t size = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, @@ -4521,7 +4521,7 @@ static int mdbx_page_flush(MDBX_txn *txn, pgno_t keep) { /* Write previous page(s) */ rc = mdbx_pwritev(env->me_fd, iov, n, wpos, wsize); if (unlikely(rc != MDBX_SUCCESS)) { - mdbx_debug("Write error: %s", strerror(rc)); + mdbx_debug("Write error: %s", mdbx_strerror(rc)); return rc; } n = 0; diff --git a/src/tools/mdbx_dump.c b/src/tools/mdbx_dump.c index ea53013f..d1621562 100644 --- a/src/tools/mdbx_dump.c +++ b/src/tools/mdbx_dump.c @@ -203,7 +203,8 @@ int main(int argc, char *argv[]) { break; case 'f': if (freopen(optarg, "w", stdout) == NULL) { - fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg, strerror(errno)); + fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg, + mdbx_strerror(errno)); exit(EXIT_FAILURE); } break; diff --git a/src/tools/mdbx_load.c b/src/tools/mdbx_load.c index 5eb3ec19..661336c6 100644 --- a/src/tools/mdbx_load.c +++ b/src/tools/mdbx_load.c @@ -340,7 +340,8 @@ int main(int argc, char *argv[]) { break; case 'f': if (freopen(optarg, "r", stdin) == NULL) { - fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg, strerror(errno)); + fprintf(stderr, "%s: %s: reopen: %s\n", prog, optarg, + mdbx_strerror(errno)); exit(EXIT_FAILURE); } break;