1 #ifndef _WIMLIB_ERROR_H
2 #define _WIMLIB_ERROR_H
6 #include "wimlib.h" /* Get error code definitions */
7 #include "wimlib/compiler.h"
8 #include "wimlib/types.h"
10 static inline int _format_attribute(printf, 1, 2)
11 dummy_tprintf(const tchar *format, ...)
16 #ifdef ENABLE_ERROR_MESSAGES
18 wimlib_error(const tchar *format, ...)
19 _format_attribute(printf, 1, 2) _cold_attribute;
22 wimlib_error_with_errno(const tchar *format, ...)
23 _format_attribute(printf, 1, 2) _cold_attribute;
26 wimlib_warning(const tchar *format, ...)
27 _format_attribute(printf, 1, 2) _cold_attribute;
30 wimlib_warning_with_errno(const tchar *format, ...)
31 _format_attribute(printf, 1, 2) _cold_attribute;
32 # define ERROR(format, ...) wimlib_error(T(format), ## __VA_ARGS__)
33 # define ERROR_WITH_ERRNO(format, ...) wimlib_error_with_errno(T(format), ## __VA_ARGS__)
34 # define WARNING(format, ...) wimlib_warning(T(format), ## __VA_ARGS__)
35 # define WARNING_WITH_ERRNO(format, ...) wimlib_warning_with_errno(T(format), ## __VA_ARGS__)
36 extern bool wimlib_print_errors;
37 extern FILE *wimlib_error_file;
38 #else /* ENABLE_ERROR_MESSAGES */
39 # define wimlib_print_errors 0
40 # define wimlib_error_file NULL
41 # define ERROR(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
42 # define ERROR_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
43 # define WARNING(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
44 # define WARNING_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
45 #endif /* !ENABLE_ERROR_MESSAGES */
49 wimlib_debug(const tchar *file, int line, const char *func,
50 const tchar *format, ...);
51 # define DEBUG(format, ...) \
52 wimlib_debug(T(__FILE__), __LINE__, __func__, T(format), ## __VA_ARGS__)
55 # define DEBUG(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
56 #endif /* !ENABLE_DEBUG */
59 print_byte_field(const u8 *field, size_t len, FILE *out);
61 #endif /* _WIMLIB_ERROR_H */