From aec20d4fe3e034e00745c04572c0594e49fa1ae6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 17 Jul 2021 14:22:50 +0100 Subject: [PATCH] Work around missing inttypes.h in older MSVC versions Use stdint.h instead when available or define the required types and constants ourselves for even older versions. --- src/wx/pcre2.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/wx/pcre2.h b/src/wx/pcre2.h index 7ab6b39..c31520f 100644 --- a/src/wx/pcre2.h +++ b/src/wx/pcre2.h @@ -89,7 +89,40 @@ the relevant values must be provided by some other means. */ #include #include + +/* Versions of MSVC < 2013 don't have inttypes.h, but 2010 and later have +stdint.h, which is sufficient here. For even older versions we have to use +wx replacements. */ +#if defined(_MSC_VER) + #if _MSC_VER < 1600 + #include "wx/types.h" + #define wxNO_INTTYPES_H + + #define INT8_MAX 0x7f + #define UINT8_MAX 0xff + + #define INT16_MAX 0x7fff + #define UINT16_MAX 0xffff + + #define INT32_MAX 0x7fffffff + #define UINT32_MAX 0xffffffff + + typedef wxInt8 int8_t; + typedef wxUint8 uint8_t; + + typedef wxInt16 int16_t; + typedef wxUint16 uint16_t; + + typedef wxInt32 int32_t; + typedef wxUint32 uint32_t; + #elif _MSC_VER < 1800 + #include + #define wxNO_INTTYPES_H + #endif +#endif +#ifndef wxNO_INTTYPES_H #include +#endif /* Allow for C++ users compiling this directly. */