diff --git a/cmdline/portable.h b/cmdline/portable.h index 7b3cdc03..6d657d8e 100644 --- a/cmdline/portable.h +++ b/cmdline/portable.h @@ -32,6 +32,19 @@ #include #endif +/** + * Specify the format attribute for printf. + */ +#ifdef __MINGW32__ +#ifdef __USE_MINGW_ANSI_STDIO +#define attribute_printf gnu_printf /* GNU format */ +#else +#define attribute_printf ms_printf /* MSVCRT format */ +#endif +#else +#define attribute_printf printf /* GNU format is the default one */ +#endif + /** * Compiler extension */ diff --git a/cmdline/support.h b/cmdline/support.h index 6412d040..b462d721 100644 --- a/cmdline/support.h +++ b/cmdline/support.h @@ -29,7 +29,7 @@ * * These messages go in the log file and in stdout. */ -void fout(const char* format, ...) __attribute__((format(printf, 1, 2))); +void fout(const char* format, ...) __attribute__((format(attribute_printf, 1, 2))); /** * Error messages printed before an early termination. @@ -39,7 +39,7 @@ void fout(const char* format, ...) __attribute__((format(printf, 1, 2))); * * These messages go in the log file and in stderr. */ -void ferr(const char* format, ...) __attribute__((format(printf, 1, 2))); +void ferr(const char* format, ...) __attribute__((format(attribute_printf, 1, 2))); /** * Log messages printed after an error. @@ -49,7 +49,7 @@ void ferr(const char* format, ...) __attribute__((format(printf, 1, 2))); * * These messages go in the log file if specified, otherwise in stderr. */ -void flog(const char* format, ...) __attribute__((format(printf, 1, 2))); +void flog(const char* format, ...) __attribute__((format(attribute_printf, 1, 2))); /** * Flush the log output. @@ -63,7 +63,7 @@ void fflush_log(void); * * These messages go in the log file. */ -void ftag(const char* format, ...) __attribute__((format(printf, 1, 2))); +void ftag(const char* format, ...) __attribute__((format(attribute_printf, 1, 2))); /** * Pointer to log function. @@ -116,7 +116,7 @@ void pathexport(char* dst, size_t size, const char* src); * Prints a path. * Aborts if too long. */ -void pathprint(char* dst, size_t size, const char* format, ...) __attribute__((format(printf, 3, 4))); +void pathprint(char* dst, size_t size, const char* format, ...) __attribute__((format(attribute_printf, 3, 4))); /** * Ensures the presence of a terminating slash, if it isn't empty.