diff --git a/maperror.h b/maperror.h index fe6bf4d34c..0ed965cb00 100644 --- a/maperror.h +++ b/maperror.h @@ -92,6 +92,14 @@ extern "C" { # define MS_DLL_EXPORT __declspec(dllexport) #else #define MS_DLL_EXPORT +#endif + +#ifndef MS_PRINT_FUNC_FORMAT +#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP) +#define MS_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#else +#define MS_PRINT_FUNC_FORMAT( format_idx, arg_idx ) +#endif #endif typedef struct errorObj { @@ -114,7 +122,7 @@ extern "C" { MS_DLL_EXPORT char *msGetErrorString(char *delimiter); #ifndef SWIG - MS_DLL_EXPORT void msSetError(int code, const char *message, const char *routine, ...); + MS_DLL_EXPORT void msSetError(int code, const char *message, const char *routine, ...) MS_PRINT_FUNC_FORMAT(2,4) ; MS_DLL_EXPORT void msWriteError(FILE *stream); MS_DLL_EXPORT void msWriteErrorXML(FILE *stream); MS_DLL_EXPORT char *msGetErrorCodeString(int code); @@ -157,7 +165,7 @@ extern "C" { } debugInfoObj; - MS_DLL_EXPORT void msDebug( const char * pszFormat, ... ); + MS_DLL_EXPORT void msDebug( const char * pszFormat, ... ) MS_PRINT_FUNC_FORMAT(1,2) ; MS_DLL_EXPORT int msSetErrorFile(const char *pszErrorFile, const char *pszRelToPath); MS_DLL_EXPORT void msCloseErrorFile( void ); MS_DLL_EXPORT const char *msGetErrorFile( void ); diff --git a/mapio.h b/mapio.h index 0a559ee08c..b5faef2a44 100644 --- a/mapio.h +++ b/mapio.h @@ -40,11 +40,19 @@ #ifdef __cplusplus extern "C" { +#endif + +#ifndef MS_PRINT_FUNC_FORMAT +#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP) +#define MS_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#else +#define MS_PRINT_FUNC_FORMAT( format_idx, arg_idx ) +#endif #endif /* stdio analogs */ - int MS_DLL_EXPORT msIO_printf( const char *format, ... ); - int MS_DLL_EXPORT msIO_fprintf( FILE *stream, const char *format, ... ); + int MS_DLL_EXPORT msIO_printf( const char *format, ... ) MS_PRINT_FUNC_FORMAT(1,2); + int MS_DLL_EXPORT msIO_fprintf( FILE *stream, const char *format, ... ) MS_PRINT_FUNC_FORMAT(2,3); int MS_DLL_EXPORT msIO_fwrite( const void *ptr, size_t size, size_t nmemb, FILE *stream ); int MS_DLL_EXPORT msIO_fread( void *ptr, size_t size, size_t nmemb, FILE *stream ); int MS_DLL_EXPORT msIO_vfprintf( FILE *fp, const char *format, va_list ap ); @@ -71,7 +79,7 @@ extern "C" { msIOContext *stdout_context, msIOContext *stderr_context ); msIOContext MS_DLL_EXPORT *msIO_getHandler( FILE * ); - void msIO_setHeader (const char *header, const char* value, ...); + void msIO_setHeader (const char *header, const char* value, ...) MS_PRINT_FUNC_FORMAT(2,3); void msIO_sendHeaders(void); /*