Skip to content

Commit

Permalink
debug.h: MSG: allow MOD_NAME to be a varible
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MartinPulec committed Jun 3, 2024
1 parent 63b524c commit 1454e66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ void debug_file_dump(const char *key, void (*serialize)(const void *data, FILE *
void log_msg(int log_level, const char *format, ...) __attribute__((format (printf, 2, 3)));
void log_msg_once(int log_level, uint32_t id, const char *msg, ...) __attribute__((format (printf, 3, 4)));
void log_perror(int log_level, const char *msg);
#define MSG(l, ...) log_msg(LOG_LEVEL_ ## l, MOD_NAME __VA_ARGS__)
#define MSG(l, fmt, ...) \
log_msg(LOG_LEVEL_##l, "%s" fmt, MOD_NAME, ##__VA_ARGS__)

bool parse_log_cfg(const char *conf_str,
int *log_lvl,
Expand Down

0 comments on commit 1454e66

Please sign in to comment.