GCC style printf attrib for checking correct usage of format arguments

Defined RXI_LOGC_FMT_ATTRIB which expands to nothing in case __GNUC__ is not defined.
It's purpose is to provide printf style checking enforced from the compiler where supported
This commit is contained in:
Davide Paro 2021-02-12 00:22:47 +01:00 committed by GitHub
parent f9ea34994b
commit 3e5970eb11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,13 @@ void log_set_quiet(bool enable);
int log_add_callback(log_LogFn fn, void *udata, int level); int log_add_callback(log_LogFn fn, void *udata, int level);
int log_add_fp(FILE *fp, int level); int log_add_fp(FILE *fp, int level);
void log_log(int level, const char *file, int line, const char *fmt, ...); #define RXI_LOGC_FMT_ATTRIB(n, m)
#if defined __GNUC__
# define RXI_LOGC_FMT_ATTRIB(n, m) __attribute__((format(printf, n, m)))
#endif
void log_log(int level, const char *file, int line, const char *fmt, ...) RXI_LOGC_FMT_ATTRIB(4, 5);
#endif #endif