Permalink
Browse files

Add MS_PRINT_FUNC_FORMAT() macro to be able to decorate printf()-like…

… functions, like msSetError(), msDebug(), msIO_printf(), etc...
  • Loading branch information...
rouault committed Jul 6, 2013
1 parent dfea815 commit 77f9b811d39156f012eb8bf765a9ffc3e1dbed2c
Showing with 21 additions and 5 deletions.
  1. +10 −2 maperror.h
  2. +11 −3 mapio.h
View
@@ -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 );
View
14 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);
/*

0 comments on commit 77f9b81

Please sign in to comment.