-wimlib_warning_with_errno(const char *format, ...) FORMAT(printf, 1, 2) COLD;
-# define ERROR wimlib_error
-# define ERROR_WITH_ERRNO wimlib_error_with_errno
-# define WARNING wimlib_warning
-# define WARNING_WITH_ERRNO wimlib_warning
-#else
-# define ERROR(format, ...) dummy_printf(format, ## __VA_ARGS__)
-# define ERROR_WITH_ERRNO(format, ...) dummy_printf(format, ## __VA_ARGS__)
-# define WARNING(format, ...) dummy_printf(format, ## __VA_ARGS__)
-# define WARNING_WITH_ERRNO(format, ...) dummy_printf(format, ## __VA_ARGS__)
-#endif /* ENABLE_ERROR_MESSAGES */
-
-#if defined(ENABLE_DEBUG) || defined(ENABLE_MORE_DEBUG)
-# include <errno.h>
-# define DEBUG(format, ...) \
- ({ \
- int __errno_save = errno; \
- wimlib_fprintf(stdout, "[%s %d] %s(): " format, \
- __FILE__, __LINE__, __func__, ## __VA_ARGS__); \
- putchar('\n'); \
- fflush(stdout); \
- errno = __errno_save; \
- })
+wimlib_warning_with_errno(const tchar *format, ...) FORMAT(printf, 1, 2) COLD;
+# define ERROR(format, ...) wimlib_error(T(format), ## __VA_ARGS__)
+# define ERROR_WITH_ERRNO(format, ...) wimlib_error_with_errno(T(format), ## __VA_ARGS__)
+# define WARNING(format, ...) wimlib_warning(T(format), ## __VA_ARGS__)
+# define WARNING_WITH_ERRNO(format, ...) wimlib_warning(T(format), ## __VA_ARGS__)
+#else /* ENABLE_ERROR_MESSAGES */
+# define ERROR(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
+# define ERROR_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
+# define WARNING(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
+# define WARNING_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
+#endif /* !ENABLE_ERROR_MESSAGES */
+
+#if defined(ENABLE_MORE_DEBUG) && !defined(ENABLE_DEBUG)
+# define ENABLE_DEBUG 1
+#endif
+
+#if defined(ENABLE_MORE_ASSERTIONS) && !defined(ENABLE_ASSERTIONS)
+# define ENABLE_ASSERTIONS 1
+#endif
+
+#ifdef ENABLE_DEBUG
+extern void
+wimlib_debug(const tchar *file, int line, const char *func,
+ const tchar *format, ...);
+# define DEBUG(format, ...) \
+ wimlib_debug(T(__FILE__), __LINE__, __func__, T(format), ## __VA_ARGS__)