From 2cf1b097679d8b04926d034717dbf843d59b5f64 Mon Sep 17 00:00:00 2001 From: cpq Date: Wed, 23 Dec 2020 21:05:46 +0000 Subject: [PATCH] Workaround for WIN32 C++ snprintf/vsnprintf/strdup calls --- mongoose.h | 5 +++++ src/arch_win32.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/mongoose.h b/mongoose.h index fbf7f412..226d6e6d 100644 --- a/mongoose.h +++ b/mongoose.h @@ -254,9 +254,14 @@ enum { false = 0, true = 1 }; #endif #include + +// See https://github.com/cesanta/mongoose/issues/1047 +#ifndef __cplusplus #define snprintf _snprintf #define vsnprintf _vsnprintf #define strdup(x) _strdup(x) +#endif + typedef int socklen_t; #define PATH_MAX MAX_PATH #define MG_DIRSEP '\\' diff --git a/src/arch_win32.h b/src/arch_win32.h index e842768f..f12aafa8 100644 --- a/src/arch_win32.h +++ b/src/arch_win32.h @@ -18,9 +18,15 @@ enum { false = 0, true = 1 }; #endif #include + +// Protect from calls like std::snprintf in app code +// See https://github.com/cesanta/mongoose/issues/1047 +#ifndef __cplusplus #define snprintf _snprintf #define vsnprintf _vsnprintf #define strdup(x) _strdup(x) +#endif + typedef int socklen_t; #define PATH_MAX MAX_PATH #define MG_DIRSEP '\\'