36# define __FUNCTION__ __func__
40# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
43# ifdef __SCO_VERSION__
44# define __inline__ inline
46# define __inline__ __inline
53# ifndef __has_attribute
54# define __has_attribute(x) 0
57# define __has_feature(x) 0
59# ifndef __has_extension
60# define __has_extension __has_feature
62# define M_COMPILER_SUPPORTS(ATTR, VER) (__has_attribute(ATTR) || __has_extension(ATTR))
63#elif defined(__GNUC__)
64# define M_COMPILER_SUPPORTS(ATTR, VER) (GCC_VERSION >= VER)
66# define M_COMPILER_SUPPORTS(ATTR, VER) 0
76#if defined(__cplusplus)
77# define __BEGIN_DECLS extern "C" {
90# define M_DLL_IMPORT __declspec(dllimport)
91# define M_DLL_EXPORT __declspec(dllexport)
92#elif M_COMPILER_SUPPORTS(visibility, 40000)
93# define M_DLL_IMPORT __attribute__((visibility ("default")))
94# define M_DLL_EXPORT __attribute__((visibility ("default")))
103#if defined(MSTDLIB_STATIC)
106# define M_API M_DLL_EXPORT
108# define M_API M_DLL_IMPORT
114#if M_COMPILER_SUPPORTS(malloc, 0)
118# define M_MALLOC __attribute__((malloc))
119# define M_MALLOC_ALIASED
122# define M_MALLOC_ALIASED
127#if M_COMPILER_SUPPORTS(__deprecated__, 0)
129# define M_DEPRECATED(proto) proto __attribute__((__deprecated__))
131# define M_DEPRECATED(proto) proto
134#if M_COMPILER_SUPPORTS(__format__, 0) && !defined(_WIN32)
136# define M_PRINTF(fmt_idx, arg_idx) __attribute__((__format__(__printf__,fmt_idx,arg_idx)))
138# define M_PRINTF(fmtarg, firstvararg)
144#if M_COMPILER_SUPPORTS(warn_unused_result, 30400)
145# define M_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
147# define M_WARN_UNUSED_RESULT
155#if !defined(MSTDLIB_INTERNAL) && M_COMPILER_SUPPORTS(nonnull, 30400)
156# define M_WARN_NONNULL(arg) __attribute__((nonnull(arg)))
159# define M_WARN_NONNULL(arg)
165#if M_COMPILER_SUPPORTS(alloc_size, 40300)
166# define M_ALLOC_SIZE(size) __attribute__((alloc_size(size)))
168# define M_ALLOC_SIZE(size)
173#if defined(__GNUC__) && !defined(M_BLACKLIST_FUNC)
174# define M_BLACKLIST_FUNC 1
185#if defined(__GNUC__) && !defined(__clang__) && (GCC_VERSION >= 40500) && !defined(QT_VERSION) && !defined(_WIN32)
186# define M_DEPRECATED_MSG(msg,proto) proto __attribute__((deprecated(msg)));
188# define M_DEPRECATED_MSG(msg,proto)
193#define M_DEPRECATED_FOR(f,proto) M_DEPRECATED_MSG("Use " #f " instead", proto)
195#if defined(__clang__)
196# define M_BEGIN_IGNORE_DEPRECATIONS _Pragma ("clang diagnostic push") \
197 _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"")
198# define M_END_IGNORE_DEPRECATIONS _Pragma ("clang diagnostic pop")
199# define M_BEGIN_IGNORE_REDECLARATIONS _Pragma ("clang diagnostic push") \
200 _Pragma ("clang diagnostic ignored \"-Wredundant-decls\"")
201# define M_END_IGNORE_REDECLARATIONS _Pragma ("clang diagnostic pop")
202#elif defined(__GNUC__) && GCC_VERSION >= 40600
203# define M_BEGIN_IGNORE_DEPRECATIONS _Pragma ("GCC diagnostic push") \
204 _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
205# define M_END_IGNORE_DEPRECATIONS _Pragma ("GCC diagnostic pop")
206# define M_BEGIN_IGNORE_REDECLARATIONS _Pragma ("GCC diagnostic push") \
207 _Pragma ("GCC diagnostic ignored \"-Wredundant-decls\"")
208# define M_END_IGNORE_REDECLARATIONS _Pragma ("GCC diagnostic pop")
210# define M_BEGIN_IGNORE_DEPRECATIONS
211# define M_END_IGNORE_DEPRECATIONS
212# define M_BEGIN_IGNORE_REDECLARATIONS
213# define M_END_IGNORE_REDECLARATIONS
214# undef m_blacklist_func
215# define m_blacklist_func 0
216# define m_begin_ignore_redeclarations
217# define m_end_ignore_redeclarations
221#define M_WARNING_STR(s) #s
222#define M_WARNING_JOINSTR(x,y) M_WARNING_STR(x ## y)
224# define M_WARNING_PRAGMA(x) __pragma (warning(x))
225#elif defined(__clang__)
226# define M_WARNING_PRAGMA(x) _Pragma (M_WARNING_STR(clang diagnostic x))
227#elif defined(__GNUC__)
228# define M_WARNING_PRAGMA(x) _Pragma (M_WARNING_STR(GCC diagnostic x))
230# define M_WARNING_PRAGMA(x)
232#define M_WARNING_CANCEL() M_WARNING_PRAGMA(pop)
233#if defined(__clang__)
234# define M_WARNING_DISABLE(gcc_unused,clang_option,msvc_unused) M_WARNING_PRAGMA(push) M_WARNING_PRAGMA(ignored M_WARNING_JOINSTR(-W,clang_option))
235# define M_WARNING_ENABLE(gcc_unused,clang_option,msvc_unused) M_WARNING_PRAGMA(push) M_WARNING_PRAGMA(M_WARNING_JOINSTR(-W,clang_option))
236#elif defined(_MSC_VER)
237# define M_WARNING_DISABLE(gcc_unused,clang_unused,msvc_errorcode) M_WARNING_PRAGMA(push) M_WARNING_PRAGMA(disable: msvc_errorcode)
238# define M_WARNING_ENABLE(gcc_unused,clang_unused,msvc_errorcode) M_WARNING_PRAGMA(push) M_WARNING_PRAGMA(msvc_errorcode)
239#elif defined(__GNUC__)
240# define M_WARNING_DISABLE(gcc_option,clang_unused,msvc_unused) M_WARNING_PRAGMA(push) M_WARNING_PRAGMA(ignored M_WARNING_JOINSTR(-W,gcc_option))
241# define M_WARNING_ENABLE(gcc_option,clang_unused,msvc_unused) M_WARNING_PRAGMA(push) M_WARNING_PRAGMA(warning M_WARNING_JOINSTR(-W,gcc_option))
243# define M_WARNING_DISABLE(gcc_option,clang_unused,msvc_unsued)
244# define M_WARNING_ENABLE(gcc_option,clang_unused,msvc_unsued)
250#define M_CAST_OFF_CONST(type, var) ((type)((M_uintptr)var))