diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/cbasetypes.h | 6 | ||||
-rw-r--r-- | src/common/strlib.h | 21 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 3fc41bb23..89f7f8588 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -460,12 +460,6 @@ typedef char bool; #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L // C11 version #define STATIC_ASSERT(ex, msg) _Static_assert(ex, msg) -#elif __has_feature(c_static_assert) -// Clang support (as per http://clang.llvm.org/docs/LanguageExtensions.html) -#define STATIC_ASSERT(ex, msg) _Static_assert(ex, msg) -#elif defined(__GNUC__) && GCC_VERSION >= 40700 -// GCC >= 4.7 is known to support it -#define STATIC_ASSERT(ex, msg) _Static_assert(ex, msg) #elif defined(_MSC_VER) // MSVC doesn't support it, but it accepts the C++ style version #define STATIC_ASSERT(ex, msg) static_assert(ex, msg) diff --git a/src/common/strlib.h b/src/common/strlib.h index 5ea4f4763..006bbd14b 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -49,6 +49,27 @@ #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf_((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline_((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex_((output),(input),(count))) +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +#if defined(__GNUC__) && !defined(__clang__) && GCC_VERSION < 40900 +// _Generic is only supported starting with GCC 4.9 +#else +#ifdef strchr +#undef strchr +#endif // strchr +#define strchr(src, chr) _Generic((src), \ + const char * : ((const char *)(strchr)((src), (chr))), \ + char * : ((strchr)((src), (chr))) \ + ) +#define strrchr(src, chr) _Generic((src), \ + const char * : ((const char *)(strrchr)((src), (chr))), \ + char * : ((strrchr)((src), (chr))) \ + ) +#define strstr(haystack, needle) _Generic((haystack), \ + const char * : ((const char *)(strstr)((haystack), (needle))), \ + char * : ((strstr)((haystack), (needle))) \ + ) +#endif +#endif /// Bitfield determining the behavior of sv_parse and sv_split. typedef enum e_svopt { |