Skip to content

Commit 41c5738

Browse files
esyr-rhldv-alt
authored andcommittedDec 13, 2017
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.
1 parent 859bc34 commit 41c5738

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎error_prints.h

+14
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,18 @@ void error_msg_and_die(const char *fmt, ...)
6262
perror_msg(__VA_ARGS__); \
6363
} while (0)
6464

65+
/* Simple wrappers for providing function name in error messages */
66+
#define error_func_msg(fmt_, ...) \
67+
error_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
68+
#define perror_func_msg(fmt_, ...) \
69+
perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
70+
#define debug_func_msg(fmt_, ...) \
71+
debug_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
72+
#define debug_func_perror_msg(fmt_, ...) \
73+
debug_perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
74+
#define error_func_msg_and_die(fmt_, ...) \
75+
error_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
76+
#define perror_func_msg_and_die(fmt_, ...) \
77+
perror_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
78+
6579
#endif /* !STRACE_ERROR_PRINTS_H */

0 commit comments

Comments
 (0)
Please sign in to comment.