diff options
author | Haru <haru@dotalux.com> | 2018-08-26 15:03:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-26 15:03:22 +0200 |
commit | 42f36d1ee5dcc89e288c6ac128be0ff6ed0985e0 (patch) | |
tree | 4b164ce3b338c216787403e79898facb00834231 /src/common/strlib.h | |
parent | 234189f34e5f055c82654b8cd35330822e8aa4d7 (diff) | |
parent | 4da22050a04f9cd45097dbdc678ab20971f5570b (diff) | |
download | hercules-42f36d1ee5dcc89e288c6ac128be0ff6ed0985e0.tar.gz hercules-42f36d1ee5dcc89e288c6ac128be0ff6ed0985e0.tar.bz2 hercules-42f36d1ee5dcc89e288c6ac128be0ff6ed0985e0.tar.xz hercules-42f36d1ee5dcc89e288c6ac128be0ff6ed0985e0.zip |
Merge pull request #2189 from MishimaHaruna/c11
Change the language specification to C11 in the autoconf-based builds
Diffstat (limited to 'src/common/strlib.h')
-rw-r--r-- | src/common/strlib.h | 21 |
1 files changed, 21 insertions, 0 deletions
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 { |