]> wimlib.net Git - wimlib/blobdiff - src/util.c
Windows native build
[wimlib] / src / util.c
index 9db817ac5549d666a646280a154893a0fd7eec86..31b51ff41314e0f3d4d96e8435f73dc0418ae974 100644 (file)
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
+#include "config.h"
+
+#define MINGW_HAS_SECURE_API
+
 #undef _GNU_SOURCE
 /* Make sure the POSIX-compatible strerror_r() is declared, rather than the GNU
  * version, which has a different return type. */
 #undef _GNU_SOURCE
 /* Make sure the POSIX-compatible strerror_r() is declared, rather than the GNU
  * version, which has a different return type. */
 
 #include <unistd.h> /* for getpid() */
 
 
 #include <unistd.h> /* for getpid() */
 
+/* Windoze compatibility */
+#ifdef __WIN32__
+#  define strerror_r(errnum, buf, bufsize) strerror_s(buf, bufsize, errnum)
+#endif
+
 /* True if wimlib is to print an informational message when an error occurs.
  * This can be turned off by calling wimlib_set_print_errors(false). */
 #ifdef ENABLE_ERROR_MESSAGES
 /* True if wimlib is to print an informational message when an error occurs.
  * This can be turned off by calling wimlib_set_print_errors(false). */
 #ifdef ENABLE_ERROR_MESSAGES
@@ -54,7 +63,8 @@ static void wimlib_vmsg(const char *tag, const char *format,
                vfprintf(stderr, format, va);
                if (perror && errno_save != 0) {
                        char buf[50];
                vfprintf(stderr, format, va);
                if (perror && errno_save != 0) {
                        char buf[50];
-                       int res = strerror_r(errno_save, buf, sizeof(buf));
+                       int res;
+                       res = strerror_r(errno_save, buf, sizeof(buf));
                        if (res) {
                                snprintf(buf, sizeof(buf),
                                         "unknown error (errno=%d)", errno_save);
                        if (res) {
                                snprintf(buf, sizeof(buf),
                                         "unknown error (errno=%d)", errno_save);