Fix the printf attribute for MingW

This commit is contained in:
Andrea Mazzoleni 2015-02-16 18:42:52 +01:00
parent 14c8307ed4
commit fba7cdcbe2
2 changed files with 18 additions and 5 deletions

View file

@ -32,6 +32,19 @@
#include <windows.h>
#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
*/

View file

@ -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.