google/gumbo-parser

MSVC: <strings.h> does not exist in Windows

kolomenkin opened this issue · 2 comments

There is no <strings.h> in Windows.

Only two functions are needed by gumbo parser from <strings.h>:

  • strcasecmp
  • strncasecmp

_stricmp from <string.h> completely does the same as strcasecmp
_strnicmp from <string.h> completely does the same as strncasecmp

Here is my solution for Windows:

#if defined(_WIN32) || defined(_WIN64) 
#  include <string.h>
#  define strcasecmp _stricmp 
#  define strncasecmp _strnicmp 
#else
#  include <strings.h>
#endif

This solution doesn't work because compilers on Linux don't handle directory paths the same way as Visual Studio does. They always search user paths before system paths, and so the #include <strings.h> results in a circular include that never exits.

We could have file like local_strings.h with the code from my proposal.
And update Gumbo parser to include "local_strings.h" instead of <strings.h>

It will avoid the problem with include recursion.