mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-31 08:57:40 +00:00
Fix format string warnings for width-based integers
The DJGPP compiler emits many warnings for conflicts between print format specifiers and argument types. To fix the warnings, I added `SDL_PRIx32` macros for use with `Sint32` and `Uint32` types. The macros alias those found in <inttypes.h> or fallback to a reasonable default. As an alternative, print arguments could be cast to plain old integers. I opted slightly for the current solution as it felt more technically correct, despite making the format strings more verbose.
This commit is contained in:
parent
5427f4861b
commit
f443a6fc7a
5 changed files with 89 additions and 62 deletions
|
@ -223,7 +223,7 @@ typedef uint64_t Uint64;
|
|||
|
||||
/* @} *//* Basic data types */
|
||||
|
||||
/* Make sure we have macros for printing 64 bit values.
|
||||
/* Make sure we have macros for printing width-based integers.
|
||||
* <stdint.h> should define these but this is not true all platforms.
|
||||
* (for example win32) */
|
||||
#ifndef SDL_PRIs64
|
||||
|
@ -270,6 +270,34 @@ typedef uint64_t Uint64;
|
|||
#define SDL_PRIX64 "llX"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIs32
|
||||
#ifdef PRId32
|
||||
#define SDL_PRIs32 PRId32
|
||||
#else
|
||||
#define SDL_PRIs32 "d"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIu32
|
||||
#ifdef PRIu32
|
||||
#define SDL_PRIu32 PRIu32
|
||||
#else
|
||||
#define SDL_PRIu32 "u"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIx32
|
||||
#ifdef PRIx32
|
||||
#define SDL_PRIx32 PRIx32
|
||||
#else
|
||||
#define SDL_PRIx32 "x"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIX32
|
||||
#ifdef PRIX32
|
||||
#define SDL_PRIX32 PRIX32
|
||||
#else
|
||||
#define SDL_PRIX32 "X"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Annotations to help code analysis tools */
|
||||
#ifdef SDL_DISABLE_ANALYZE_MACROS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue