1 #ifndef _WIMLIB_ERROR_H
2 #define _WIMLIB_ERROR_H
4 #include "wimlib.h" /* Get error code definitions */
5 #include "wimlib/compiler.h"
6 #include "wimlib/types.h"
11 # define wimlib_fprintf fwprintf
12 # define wimlib_printf wprintf
15 wimlib_fprintf(FILE *fp, const tchar *format, ...) FORMAT(printf, 2, 3);
18 wimlib_printf(const tchar *format, ...) FORMAT(printf, 1, 2);
19 #endif /* !__WIN32__ */
22 static inline int dummy_tprintf(const tchar *format, ...)
27 #ifdef ENABLE_ERROR_MESSAGES
29 wimlib_error(const tchar *format, ...) FORMAT(printf, 1, 2) COLD;
32 wimlib_error_with_errno(const tchar *format, ...) FORMAT(printf, 1, 2) COLD;
35 wimlib_warning(const tchar *format, ...) FORMAT(printf, 1, 2) COLD;
38 wimlib_warning_with_errno(const tchar *format, ...) FORMAT(printf, 1, 2) COLD;
39 # define ERROR(format, ...) wimlib_error(T(format), ## __VA_ARGS__)
40 # define ERROR_WITH_ERRNO(format, ...) wimlib_error_with_errno(T(format), ## __VA_ARGS__)
41 # define WARNING(format, ...) wimlib_warning(T(format), ## __VA_ARGS__)
42 # define WARNING_WITH_ERRNO(format, ...) wimlib_warning_with_errno(T(format), ## __VA_ARGS__)
43 #else /* ENABLE_ERROR_MESSAGES */
44 # define ERROR(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
45 # define ERROR_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
46 # define WARNING(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
47 # define WARNING_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
48 #endif /* !ENABLE_ERROR_MESSAGES */
50 #if defined(ENABLE_MORE_DEBUG) && !defined(ENABLE_DEBUG)
51 # define ENABLE_DEBUG 1
54 #if defined(ENABLE_MORE_ASSERTIONS) && !defined(ENABLE_ASSERTIONS)
55 # define ENABLE_ASSERTIONS 1
60 wimlib_debug(const tchar *file, int line, const char *func,
61 const tchar *format, ...);
62 # define DEBUG(format, ...) \
63 wimlib_debug(T(__FILE__), __LINE__, __func__, T(format), ## __VA_ARGS__)
66 # define DEBUG(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
67 #endif /* !ENABLE_DEBUG */
69 #ifdef ENABLE_MORE_DEBUG
70 # define DEBUG2(format, ...) DEBUG(format, ## __VA_ARGS__)
72 # define DEBUG2(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
73 #endif /* !ENABLE_MORE_DEBUG */
75 #endif /* _WIMLIB_ERROR_H */