Mark log functions as printf-type functions.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2344 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2006-05-03 21:17:12 +00:00
parent 85eaa409e6
commit dcc59f4cf8
2 changed files with 25 additions and 4 deletions
+17
View File
@@ -154,5 +154,22 @@ typedef unsigned int wint_t;
# define SDL_IMAGE_INCLUDE(file) <file> # define SDL_IMAGE_INCLUDE(file) <file>
#endif /* SDL_IMAGE_DIR */ #endif /* SDL_IMAGE_DIR */
// Mark a function as using printf-style function arguments, so that
// extra consistency checks can be made by the compiler.
// The first argument to PRINTF_FUNCTION and VPRINTF_FUNCTION is the
// index of the format string argument, the second is the index of
// the first argument which is specified in the format string (in the
// case of PRINTF_FUNCTION) or of the va_list argument (in the case of
// VPRINTF_FUNCTION).
#ifdef __GNUC__
# define PRINTF_FUNCTION(formatArg, firstArg) \
__attribute__((format(printf, formatArg, firstArg)))
# define VPRINTF_FUNCTION(formatArg, arglist) \
__attribute__((format(printf, formatArg, 0)))
#else
# define PRINTF_FUNCTION(formatArg, firstArg)
# define VPRINTF_FUNCTION(formatArg, arglist)
#endif
#endif /* _PORT_H */ #endif /* _PORT_H */
+8 -4
View File
@@ -44,10 +44,14 @@ typedef enum
} log_Level; } log_Level;
extern void log_add (log_Level, const char *fmt, ...); extern void log_add (log_Level, const char *fmt, ...)
extern void log_addV (log_Level, const char *fmt, va_list); PRINTF_FUNCTION(2, 3);
extern void log_add_nothread (log_Level, const char *fmt, ...); extern void log_addV (log_Level, const char *fmt, va_list)
extern void log_add_nothreadV (log_Level, const char *fmt, va_list); VPRINTF_FUNCTION(2, 3);
extern void log_add_nothread (log_Level, const char *fmt, ...)
PRINTF_FUNCTION(2, 3);
extern void log_add_nothreadV (log_Level, const char *fmt, va_list)
VPRINTF_FUNCTION(2, 3);
#endif /* _UQMLOG_H */ #endif /* _UQMLOG_H */