Mercurial > projects > ldc
diff dmd/root/root.h @ 1372:229e02867307
Fix format-string bugs by adding __attribute__((__format__)) in all applicable
places and fixing all warnings my gcc produced.
Among other things, this should fix several segfaults (including one I just
ran into).
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sun, 17 May 2009 00:15:25 +0200 |
parents | 8026319762be |
children | 9bf06e02070b |
line wrap: on
line diff
--- a/dmd/root/root.h Sat May 16 23:44:27 2009 +0200 +++ b/dmd/root/root.h Sun May 17 00:15:25 2009 +0200 @@ -18,6 +18,14 @@ #pragma once #endif +#ifndef IS_PRINTF +# ifdef __GNUC__ +# define IS_PRINTF(FMTARG) __attribute((__format__ (__printf__, (FMTARG), (FMTARG)+1) )) +# else +# define IS_PRINTF(FMTARG) +# endif +#endif + typedef size_t hash_t; #include "dchar.h" @@ -29,9 +37,9 @@ int bstrcmp(unsigned char *s1, unsigned char *s2); char *bstr2str(unsigned char *b); -void error(const char *format, ...); +void error(const char *format, ...) IS_PRINTF(1); void error(const wchar_t *format, ...); -void warning(const char *format, ...); +void warning(const char *format, ...) IS_PRINTF(1); #ifndef TYPEDEFS #define TYPEDEFS @@ -291,7 +299,7 @@ void fill0(unsigned nbytes); void align(unsigned size); void vprintf(const char *format, va_list args); - void printf(const char *format, ...); + void printf(const char *format, ...) IS_PRINTF(2); #if M_UNICODE void vprintf(const unsigned short *format, va_list args); void printf(const unsigned short *format, ...);