16#if defined (__cplusplus)
24#include "../zstd_errors.h"
34# define ERR_STATIC static __attribute__((unused))
35#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )
36# define ERR_STATIC static inline
37#elif defined(_MSC_VER)
38# define ERR_STATIC static __inline
40# define ERR_STATIC static
48#define PREFIX(name) ZSTD_error_##name
55#define ERROR(name) ZSTD_ERROR(name)
56#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
63#define CHECK_V_F(e, f) \
69#define CHECK_F(f) do { CHECK_V_F(_var_err__, f); } while (0)
93void _force_has_format_string(
const char *format, ...) {
103#define _FORCE_HAS_FORMAT_STRING(...) \
106 _force_has_format_string(__VA_ARGS__); \
110#define ERR_QUOTE(str) #str
119#define RETURN_ERROR_IF(cond, err, ...) \
122 RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
123 __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
124 _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
125 RAWLOG(3, ": " __VA_ARGS__); \
136#define RETURN_ERROR(err, ...) \
138 RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
139 __FILE__, __LINE__, ERR_QUOTE(ERROR(err))); \
140 _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
141 RAWLOG(3, ": " __VA_ARGS__); \
151#define FORWARD_IF_ERROR(err, ...) \
153 size_t const err_code = (err); \
154 if (ERR_isError(err_code)) { \
155 RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
156 __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
157 _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
158 RAWLOG(3, ": " __VA_ARGS__); \
164#if defined (__cplusplus)
const char * ERR_getErrorString(ERR_enum code)
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code)
ERR_STATIC unsigned ERR_isError(size_t code)
ERR_STATIC const char * ERR_getErrorName(size_t code)