diff --git a/code/client/cl_http_windows.c b/code/client/cl_http_windows.c index 9a6b6f75..d585521f 100644 --- a/code/client/cl_http_windows.c +++ b/code/client/cl_http_windows.c @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static HINTERNET hInternet = NULL; static HINTERNET hUrl = NULL; -static void DropIf(qboolean condition, const char *fmt, ...) +static Q_PRINTF_FUNC(2, 3) void DropIf(qboolean condition, const char *fmt, ...) { char buffer[1024]; diff --git a/code/game/bg_lib.h b/code/game/bg_lib.h index 924e92bb..31add8fe 100644 --- a/code/game/bg_lib.h +++ b/code/game/bg_lib.h @@ -94,7 +94,7 @@ int atoi( const char *string ); int _atoi( const char **stringPtr ); long strtol( const char *nptr, char **endptr, int base ); -int Q_vsnprintf( char *buffer, size_t length, const char *fmt, va_list argptr ); +int Q_vsnprintf( char *buffer, size_t length, const char *fmt, va_list argptr ) Q_PRINTF_FUNC(3, 0); int sscanf( const char *buffer, const char *fmt, ... ) Q_SCANF_FUNC(2, 3); diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 262a9eb9..dc429ea8 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -108,7 +108,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifdef __GNUC__ #define Q_UNUSED_VAR __attribute__((unused)) #define Q_NO_RETURN __attribute__((noreturn)) + +#ifdef __MINGW32__ +// For some reason MinGW wants both gnu_printf and ms_printf +#define Q_PRINTF_FUNC(fmt, va) \ + __attribute__((format(gnu_printf, fmt, va))) \ + __attribute__((format(ms_printf, fmt, va))) +#else #define Q_PRINTF_FUNC(fmt, va) __attribute__((format(printf, fmt, va))) +#endif + #define Q_SCANF_FUNC(fmt, va) __attribute__((format(scanf, fmt, va))) #define Q_ALIGN(x) __attribute__((aligned(x))) #else @@ -168,7 +177,7 @@ typedef int intptr_t; #ifdef _WIN32 // vsnprintf is ISO/IEC 9899:1999 // abstracting this to make it portable - int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap); + int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap) Q_PRINTF_FUNC(3, 0); #else #define Q_vsnprintf vsnprintf #endif