Mercurial > hg > dmlib
changeset 2385:5ffc48a0bebe
Conditionally define DM_ATTR_PRINTF_FMT(xstart, xend) instead of using
__attribute__ ((__format__ (__printf__, (xstart), (xend)))) directly.
Wrap it in an #ifdef check for __MINGW64__ as there are some annoying
issues on that side, which we just suppress now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Jan 2020 18:51:22 +0200 |
parents | 36edd316184a |
children | f543475ea0eb |
files | src/dmlib.h src/dmres.h src/dmtext.h tools/lib64util.c tools/libgutil.h |
diffstat | 5 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmlib.h Thu Jan 09 15:20:23 2020 +0200 +++ b/src/dmlib.h Thu Jan 09 18:51:22 2020 +0200 @@ -45,6 +45,14 @@ #endif +// Kludge, as MinGW64 cross-compiler does not like certain printf() format specifiers +#if defined(__MINGW64__) +# define DM_ATTR_PRINTF_FMT(xstart, xend) +#else +# define DM_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend)))) +#endif + + // Do we have a valid arch? // If so, set some printf specifiers #if DM_ARCH == 32 @@ -374,16 +382,16 @@ void dmMsgVA(int level, const char *fmt, va_list ap); void dmMsg(int level, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + DM_ATTR_PRINTF_FMT(2, 3); void dmPrintVA(int level, const char *fmt, va_list ap); void dmPrint(int level, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + DM_ATTR_PRINTF_FMT(2, 3); int dmErrorVA(const int error, const char *fmt, va_list); int dmError(const int error, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + DM_ATTR_PRINTF_FMT(2, 3); void dmErrorMsg(const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); + DM_ATTR_PRINTF_FMT(1, 2); int dmGetErrno(); const char *dmErrorStr(const int error);
--- a/src/dmres.h Thu Jan 09 15:20:23 2020 +0200 +++ b/src/dmres.h Thu Jan 09 18:51:22 2020 +0200 @@ -173,7 +173,7 @@ int dmfputs(const char *str, DMResource *fh); int dmvfprintf(DMResource *fh, const char *fmt, va_list ap); int dmfprintf(DMResource *fh, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + DM_ATTR_PRINTF_FMT(2, 3); // Helper functions for endianess based reading etc BOOL dmf_read_str(DMResource *fh, void *ptr, const size_t len);
--- a/src/dmtext.h Thu Jan 09 15:20:23 2020 +0200 +++ b/src/dmtext.h Thu Jan 09 18:51:22 2020 +0200 @@ -69,7 +69,7 @@ const BOOL condensed, const int mode, const int xc, const int yc, const char *fmt, va_list ap); void dmDrawBMText(SDL_Surface *screen, const DMBitmapFont *font, const BOOL condensed, const int mode, const int xc, const int yc, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 7, 8))); + DM_ATTR_PRINTF_FMT(7, 8); static inline void dmInitializeGetBMGlyphSurface(SDL_Surface *surf, DMBitmapFont *font)
--- a/tools/lib64util.c Thu Jan 09 15:20:23 2020 +0200 +++ b/tools/lib64util.c Thu Jan 09 18:51:22 2020 +0200 @@ -110,7 +110,7 @@ } -__attribute__ ((__format__ (__printf__, 4, 5))) +DM_ATTR_PRINTF_FMT(4, 5) static void dmC64ImageDumpLine(FILE *fh, const char *indent, const char *field, const char *fmt, ...) { va_list ap;
--- a/tools/libgutil.h Thu Jan 09 15:20:23 2020 +0200 +++ b/tools/libgutil.h Thu Jan 09 18:51:22 2020 +0200 @@ -23,7 +23,7 @@ void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt); void dmDrawBMTextVAQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap); void dmDrawBMTextQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 6, 7))); + DM_ATTR_PRINTF_FMT(6, 7); #ifdef __cplusplus