From 3474933375ee05208dc4bb6b31990c2b47d4ba84 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 7 Apr 2013 13:44:44 -0700 Subject: [PATCH] Fixed MinGW build. --- include/bx/platform.h | 9 +++++++++ include/bx/string.h | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/bx/platform.h b/include/bx/platform.h index 2537fca..552277f 100644 --- a/include/bx/platform.h +++ b/include/bx/platform.h @@ -135,4 +135,13 @@ # pragma warning(error:4505) // ENABLE warning C4505: '' : unreferenced local function has been removed #endif // BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS && BX_COMPILER_MSVC +#if BX_PLATFORM_WINDOWS +// http://msdn.microsoft.com/en-us/library/6sehtctf.aspx +# if !defined(WINVER) && !defined(_WIN32_WINNT) + // Windows 2000 and above +# define WINVER 0x0500 +# define _WIN32_WINNT 0x0500 +# endif // !defined(WINVER) && !defined(_WIN32_WINNT) +#endif // BX_PLATFORM_WINDOWS + #endif // __BX_PLATFORM_H__ diff --git a/include/bx/string.h b/include/bx/string.h index 66f3a62..4ddd249 100644 --- a/include/bx/string.h +++ b/include/bx/string.h @@ -14,6 +14,7 @@ namespace bx { + /// Case insensitive string compare. inline int32_t stricmp(const char* _a, const char* _b) { #if BX_COMPILER_MSVC @@ -23,6 +24,15 @@ namespace bx #endif // BX_COMPILER_ } + /// + inline size_t strnlen(const char* _str, size_t _max) + { + const char* end = _str + _max; + const char* ptr; + for (ptr = _str; ptr < end && *ptr != '\0'; ++ptr); + return ptr - _str; + } + /// Find substring in string. Limit search to _size. inline const char* strnstr(const char* _str, const char* _find, size_t _size) {