error_prints.h: add *_func_* printing macros

In order to reduce boilerplate for the cases when __func__ is desired
to be printed.

* error_prints.h (error_func_msg, perror_func_msg, debug_func_msg,
debug_func_perror_msg, error_func_msg_and_die, perror_func_msg_and_die):
New macro definitions.
This commit is contained in:
Eugene Syromiatnikov 2017-08-04 08:03:34 +02:00 committed by Dmitry V. Levin
parent 859bc3444c
commit 41c5738fe6

View File

@ -62,4 +62,18 @@ void error_msg_and_die(const char *fmt, ...)
perror_msg(__VA_ARGS__); \
} while (0)
/* Simple wrappers for providing function name in error messages */
#define error_func_msg(fmt_, ...) \
error_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
#define perror_func_msg(fmt_, ...) \
perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
#define debug_func_msg(fmt_, ...) \
debug_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
#define debug_func_perror_msg(fmt_, ...) \
debug_perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
#define error_func_msg_and_die(fmt_, ...) \
error_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
#define perror_func_msg_and_die(fmt_, ...) \
perror_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
#endif /* !STRACE_ERROR_PRINTS_H */