Skip to content

Commit

Permalink
fixes #4753: added MXE-specific macros to properly print format speci…
Browse files Browse the repository at this point in the history
…fiers PRIu32, PRIu64 and PRId64 (patch 3/5)
  • Loading branch information
Forgon2100 committed Feb 22, 2018
1 parent 066e900 commit 7436417
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/framework/debug.h
Expand Up @@ -261,7 +261,11 @@ bool debug_enable_switch(const char *str);
* Only outputs if debugging of part was formerly enabled with debug_enable_switch.
*/
#define debug(part, ...) do { if (enabled_debug[part]) _debug(__LINE__, part, __FUNCTION__, __VA_ARGS__); } while(0)
#ifdef WZ_CC_MINGW
void _debug(int line, code_part part, const char *function, const char *str, ...) WZ_DECL_FORMAT(__MINGW_PRINTF_FORMAT, 4, 5);
#else
void _debug(int line, code_part part, const char *function, const char *str, ...) WZ_DECL_FORMAT(printf, 4, 5);
#endif

#define debugBacktrace(part, ...) do { if (enabled_debug[part]) { _debug(__LINE__, part, __FUNCTION__, __VA_ARGS__); _debugBacktrace(part); }} while(0)
void _debugBacktrace(code_part part);
Expand Down
4 changes: 4 additions & 0 deletions lib/framework/physfs_ext.h
Expand Up @@ -96,7 +96,11 @@ static inline bool PHYSFS_readBEFloat(PHYSFS_file *file, float *val)
return (PHYSFS_readUBE32(file, readValue) != 0);
}

#ifdef WZ_CC_MINGW
bool PHYSFS_printf(PHYSFS_file *file, const char *format, ...) WZ_DECL_FORMAT(__MINGW_PRINTF_FORMAT, 2, 3);
#else
bool PHYSFS_printf(PHYSFS_file *file, const char *format, ...) WZ_DECL_FORMAT(printf, 2, 3);
#endif

/**
* @brief fgets() implemented using PHYSFS.
Expand Down
1 change: 1 addition & 0 deletions lib/framework/types.h
Expand Up @@ -72,6 +72,7 @@ typedef signed long long int64_t;
# define UINT32_MAX (4294967295U)
#endif
#else
#define __USE_MINGW_ANSI_STDIO 1
#include <stdint.h> // MSVC 2010 does have those defined
#endif
#endif
Expand Down
5 changes: 5 additions & 0 deletions lib/netplay/netplay.h
Expand Up @@ -336,7 +336,12 @@ const char *messageTypeToString(unsigned messageType);

/// Sync debugging. Only prints anything, if different players would print different things.
#define syncDebug(...) do { _syncDebug(__FUNCTION__, __VA_ARGS__); } while(0)
#ifdef WZ_CC_MINGW
void _syncDebug(const char *function, const char *str, ...) WZ_DECL_FORMAT(__MINGW_PRINTF_FORMAT, 2, 3);
#else
void _syncDebug(const char *function, const char *str, ...) WZ_DECL_FORMAT(printf, 2, 3);
#endif

/// Faster than syncDebug. Make sure that str is a format string that takes ints only.
void _syncDebugIntList(const char *function, const char *str, int *ints, size_t numInts);
#define syncDebugBacktrace() do { _syncDebugBacktrace(__FUNCTION__); } while(0)
Expand Down

0 comments on commit 7436417

Please sign in to comment.