Changeset: 0fc867af9ebf for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0fc867af9ebf Modified Files: common/stream/stream.h gdk/gdk.mx Branch: Aug2011 Log Message:
Tell compilers about printf formats. diffs (98 lines): diff --git a/common/stream/stream.h b/common/stream/stream.h --- a/common/stream/stream.h +++ b/common/stream/stream.h @@ -58,6 +58,27 @@ # endif #endif +/* defines to help the compiler check printf-style format arguments + * see the declaration of mnstr_printf below. Also see gdk.h for a + * copy of this stuff. */ +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +/* This feature is available in gcc versions 2.5 and later. */ +# ifndef __attribute__ +# define __attribute__(Spec) /* empty */ +# endif +#else +/* The __-protected variants of `format' and `printf' attributes are + * accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if !defined(__format__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) +# define __format__ format +# define __printf__ printf +# endif +#endif +#if !defined(_MSC_VER) && !defined(_In_z_) +# define _In_z_ +# define _Printf_format_string_ +#endif + #define EOT 4 #define ST_ASCII 0 @@ -92,7 +113,8 @@ stream_export int mnstr_writeIntArray(stream *s, const int *val, size_t cnt); stream_export int mnstr_readLngArray(stream *s, lng *val, size_t cnt); stream_export int mnstr_writeLngArray(stream *s, const lng *val, size_t cnt); -stream_export int mnstr_printf(stream *s, const char *format, ...); +stream_export int mnstr_printf(stream *s, _In_z_ _Printf_format_string_ const char *format, ...) + __attribute__((__format__(__printf__, 2, 3))); stream_export ssize_t mnstr_read(stream *s, void *buf, size_t elmsize, size_t cnt); stream_export ssize_t mnstr_readline(stream *s, void *buf, size_t maxcnt); stream_export ssize_t mnstr_write(stream *s, const void *buf, size_t elmsize, size_t cnt); diff --git a/gdk/gdk.mx b/gdk/gdk.mx --- a/gdk/gdk.mx +++ b/gdk/gdk.mx @@ -401,6 +401,27 @@ #endif #endif +/* defines to help the compiler check printf-style format arguments + * see the declaration of mnstr_printf below. Also see stream.h for a + * copy of this stuff. */ +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +/* This feature is available in gcc versions 2.5 and later. */ +# ifndef __attribute__ +# define __attribute__(Spec) /* empty */ +# endif +#else +/* The __-protected variants of `format' and `printf' attributes are + * accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if !defined(__format__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) +# define __format__ format +# define __printf__ printf +# endif +#endif +#if !defined(_MSC_VER) && !defined(_In_z_) +# define _In_z_ +# define _Printf_format_string_ +#endif + #ifdef __cplusplus extern "C" { #endif @@ -2441,9 +2462,12 @@ /* Data Distilleries uses ICU for internationalization of some MonetDB error messages */ -gdk_export int GDKerror(const char *format, ...); -gdk_export int GDKsyserror(const char *format, ...); -gdk_export int GDKfatal(const char *format, ...); +gdk_export int GDKerror(_In_z_ _Printf_format_string_ const char *format, ...) + __attribute__((__format__(__printf__, 1, 2))); +gdk_export int GDKsyserror(_In_z_ _Printf_format_string_ const char *format, ...) + __attribute__((__format__(__printf__, 1, 2))); +gdk_export int GDKfatal(_In_z_ _Printf_format_string_ const char *format, ...) + __attribute__((__format__(__printf__, 1, 2))); @ @h @@ -2600,7 +2624,8 @@ gdk_export void THRsetdata(int, ptr); gdk_export void *THRgetdata(int); gdk_export int THRhighwater(void); -gdk_export int THRprintf(stream *s, const char *format, ...); +gdk_export int THRprintf(stream *s, _In_z_ _Printf_format_string_ const char *format, ...) + __attribute__((__format__(__printf__, 2, 3))); gdk_export void *THRdata[16]; _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list