When compiling with Microsoft Visual Studio 2019, the compiler emits:
…\lib\cgraph\strcasecmp.h(12,64): warning C4211: nonstandard extension used:
redefined extern to static
Investigation reveals libgd defines their own `strcasecmp` shim in gd.h:
/* VS2012+ disable keyword macroizing unless _ALLOW_KEYWORD_MACROS is set
We define inline, and strcasecmp if they're missing
*/
#ifdef _MSC_VER
# define _ALLOW_KEYWORD_MACROS
# ifndef inline
# define inline __inline
# endif
# ifndef strcasecmp
# define strcasecmp _stricmp
# endif
#endif
To avoid this warning, guard Graphviz’ shim so it is only used when the libgd
shim is not in use.
Note that this also explains why MSVC is able to compile diffimg.c despite the
Graphviz shim file not being included.
#include <string.h>
+ // some third-party libraries like libgd provide their own macro-based
+ // `strcasecmp` shim, so only define our own if their’s is not in scope
+#ifndef strcasecmp
static inline int strcasecmp(const char *s1, const char *s2) {
return _stricmp(s1, s2);
}
+#endif
static inline int strncasecmp(const char *s1, const char *s2, size_t n) {
return _strnicmp(s1, s2, n);