[waffle] [PATCH 15/33] c99: use strerror_s over strerror_r under Windows

Emil Velikov emil.l.velikov at gmail.com
Mon Jul 7 10:28:22 PDT 2014


Windows/MS has dropped strerror_r support due to it _not_ being
thread-safe. At the same time, every *nix man page claims the
opposite.

The recommendation is to use strerror_s, although when building with
mingw-w64 we link against msvcrt.dll which does not provide the symbol
under Windows XP.

The issue is resolved in mingw-w64 master branch (Rev.6559), and
stable (v3.x). Any version after mingw-w64-crt 3.1.0 should be OK
(v3.1.0-2 if you're using Archlinux).

v2: Update the commit message - Archlinux package 3.1.0-3 has the fix.
v3: Move the definition to c99_compat.h

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 include/c99_compat.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/c99_compat.h b/include/c99_compat.h
index bc8ddc6..be6a1d2 100644
--- a/include/c99_compat.h
+++ b/include/c99_compat.h
@@ -97,3 +97,10 @@ c99_snprintf(char* str, size_t size, const char* format, ...)
 #include <strings.h>
 
 #endif
+
+/*
+ * strerror_r (strictly speaking not C99)
+ */
+#if defined(_WIN32)
+#define strerror_r(errno,buf,len) strerror_s(buf,len,errno)
+#endif
-- 
2.0.0



More information about the waffle mailing list