Skip to content

Commit 8e0504b

Browse files
committed
debug.h: MSG: allow MOD_NAME to be a varible
Allow the MOD_NAME to be a variable (like (constexpr const char *)). Using non-standard extension, the standard one would be __VA_OPT__. Although it is supported with MSVC 2019/2022, it requires the compiler flag /Zc:preprocessor. This version doesn't require that so use it for now. The MSVC is used to compile the CUDA code and AJA wrapper so not to complicate the things now. This syntax is supported for both GNU and MSVC: 1. https://stackoverflow.com/a/78185169 2. https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html refer to GH-375
1 parent 60592ff commit 8e0504b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/debug.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ void debug_file_dump(const char *key, void (*serialize)(const void *data, FILE *
9393
void log_msg(int log_level, const char *format, ...) __attribute__((format (printf, 2, 3)));
9494
void log_msg_once(int log_level, uint32_t id, const char *msg, ...) __attribute__((format (printf, 3, 4)));
9595
void log_perror(int log_level, const char *msg);
96-
#define MSG(l, ...) log_msg(LOG_LEVEL_ ## l, MOD_NAME __VA_ARGS__)
96+
#define MSG(l, fmt, ...) \
97+
log_msg(LOG_LEVEL_##l, "%s" fmt, MOD_NAME, ##__VA_ARGS__)
9798

9899
bool parse_log_cfg(const char *conf_str,
99100
int *log_lvl,

0 commit comments

Comments
 (0)