summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/cbasetypes.h6
-rw-r--r--src/common/strlib.h21
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/npc.c2
4 files changed, 23 insertions, 8 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 {
diff --git a/src/map/clif.c b/src/map/clif.c
index fd8a3c783..a5955a9bc 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10891,7 +10891,7 @@ static void clif_parse_WisMessage(int fd, struct map_session_data *sd)
// Lordalfa - Paperboy - To whisper NPC commands //
//-------------------------------------------------------//
if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4)) {
- const char *str = target+4; //Skip the NPC: string part.
+ char *str = target + 4; // Skip the NPC: string part.
struct npc_data *nd;
if ((nd = npc->name2id(str))) {
char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX];
diff --git a/src/map/npc.c b/src/map/npc.c
index f80f8443a..a49fb08eb 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2868,7 +2868,7 @@ static const char *npc_parse_shop(const char *w1, const char *w2, const char *w3
struct npc_item_list *items = NULL;
size_t items_count = 40; // Starting items size
- char *p;
+ const char *p;
int x, y, dir, m, i, class_;
struct npc_data *nd;
enum npc_subtype type;