From 03c9a613ef2e84aa0c227460ce70996402c65451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= Date: Thu, 31 Oct 2024 10:43:37 +0000 Subject: [PATCH] [Imp] mpt/base/detect_libc.hpp: Detect different generations of Microsoft's C library. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22036 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- src/mpt/base/detect_libc.hpp | 24 +++++++++++++++++ src/mpt/base/namespace.hpp | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/mpt/base/detect_libc.hpp b/src/mpt/base/detect_libc.hpp index 0c5420bc880..b7d3f73d716 100644 --- a/src/mpt/base/detect_libc.hpp +++ b/src/mpt/base/detect_libc.hpp @@ -17,12 +17,21 @@ #define MPT_LIBC_GENERIC 1 #elif (defined(__MINGW32__) || defined(__MINGW64__)) #define MPT_LIBC_MINGW 1 +#if defined(_UCRT) +#define MPT_LIBC_MINGW_UCRT 1 +#elif defined(__MSVCRT__) +#define MPT_LIBC_MINGW_MSVCRT 1 +#elif defined(__CRTDLL__) +#define MPT_LIBC_MINGW_CRTDLL 1 +#endif #elif (defined(__GLIBC__) || defined(__GNU_LIBRARY__)) #define MPT_LIBC_GLIBC 1 #elif defined(_UCRT) #define MPT_LIBC_MS 1 +#define MPT_LIBC_MS_UCRT 1 #elif MPT_COMPILER_MSVC #define MPT_LIBC_MS 1 +#define MPT_LIBC_MS_MSVCRT 1 #elif MPT_COMPILER_CLANG && MPT_OS_WINDOWS #define MPT_LIBC_MS 1 #elif defined(__BIONIC__) @@ -44,9 +53,24 @@ #ifndef MPT_LIBC_MINGW #define MPT_LIBC_MINGW 0 #endif +#ifndef MPT_LIBC_MINGW_UCRT +#define MPT_LIBC_MINGW_UCRT 0 +#endif +#ifndef MPT_LIBC_MINGW_MSVCRT +#define MPT_LIBC_MINGW_MSVCRT 0 +#endif +#ifndef MPT_LIBC_MINGW_CRTDLL +#define MPT_LIBC_MINGW_CRTDLL 0 +#endif #ifndef MPT_LIBC_MS #define MPT_LIBC_MS 0 #endif +#ifndef MPT_LIBC_MS_UCRT +#define MPT_LIBC_MS_UCRT 0 +#endif +#ifndef MPT_LIBC_MS_MSVCRT +#define MPT_LIBC_MS_MSVCRT 0 +#endif #ifndef MPT_LIBC_BIONIC #define MPT_LIBC_BIONIC 0 #endif diff --git a/src/mpt/base/namespace.hpp b/src/mpt/base/namespace.hpp index 568442102b9..5fb817e5497 100644 --- a/src/mpt/base/namespace.hpp +++ b/src/mpt/base/namespace.hpp @@ -31,6 +31,47 @@ #if MPT_LIBC_GENERIC #define MPT_VERSION_ABI_LIBC _ #elif MPT_LIBC_MS +#if MPT_LIBC_MS_UCRT +#if MPT_LIBC_MS_SHARED +#ifdef MPT_LIBC_MS_DEBUG +#define MPT_VERSION_ABI_LIBC UMDd +#else +#define MPT_VERSION_ABI_LIBC UMDr +#endif +#elif MPT_LIBC_MS_STATIC +#ifdef MPT_LIBC_MS_DEBUG +#define MPT_VERSION_ABI_LIBC UMTd +#else +#define MPT_VERSION_ABI_LIBC UMTr +#endif +#else +#ifdef MPT_LIBC_MS_DEBUG +#define MPT_VERSION_ABI_LIBC UMd +#else +#define MPT_VERSION_ABI_LIBC UMr +#endif +#endif +#elif MPT_LIBC_MS_MSVCRT +#if MPT_LIBC_MS_SHARED +#ifdef MPT_LIBC_MS_DEBUG +#define MPT_VERSION_ABI_LIBC MMDd +#else +#define MPT_VERSION_ABI_LIBC MMDr +#endif +#elif MPT_LIBC_MS_STATIC +#ifdef MPT_LIBC_MS_DEBUG +#define MPT_VERSION_ABI_LIBC MMTd +#else +#define MPT_VERSION_ABI_LIBC MMTr +#endif +#else +#ifdef MPT_LIBC_MS_DEBUG +#define MPT_VERSION_ABI_LIBC MMd +#else +#define MPT_VERSION_ABI_LIBC MMr +#endif +#endif +#else #if MPT_LIBC_MS_SHARED #ifdef MPT_LIBC_MS_DEBUG #define MPT_VERSION_ABI_LIBC MDd @@ -50,10 +91,19 @@ #define MPT_VERSION_ABI_LIBC Mr #endif #endif +#endif #elif MPT_LIBC_GLIBC #define MPT_VERSION_ABI_LIBC G #elif MPT_LIBC_MINGW +#if MPT_LIBC_MINGW_UCRT +#define MPT_VERSION_ABI_LIBC MWU +#elif MPT_LIBC_MINGW_MSVCRT +#define MPT_VERSION_ABI_LIBC MWM +#elif MPT_LIBC_MINGW_CRTDLL +#define MPT_VERSION_ABI_LIBC MWC +#else #define MPT_VERSION_ABI_LIBC MW +#endif #elif MPT_LIBC_BIONIC #define MPT_VERSION_ABI_LIBC B #elif MPT_LIBC_APPLE