Add SDL_PRILL? format specifiers specifically for long long type.
This commit is contained in:
parent
6f80d47d64
commit
254b36361e
2 changed files with 41 additions and 29 deletions
|
@ -100,6 +100,25 @@ void *alloca(size_t);
|
|||
# define SDL_SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
#if defined(__cplusplus)
|
||||
/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */
|
||||
#if (__cplusplus >= 201103L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||
#endif
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||
#endif
|
||||
#endif /* !SDL_COMPILE_TIME_ASSERT */
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
/* universal, but may trigger -Wunused-local-typedefs */
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check if the compiler supports a given builtin.
|
||||
* Supported by virtually all clang versions and recent gcc. Use this
|
||||
|
@ -408,7 +427,7 @@ typedef Sint64 SDL_Time;
|
|||
/* @} *//* Floating-point constants */
|
||||
|
||||
/* Make sure we have macros for printing width-based integers.
|
||||
* <stdint.h> should define these but this is not true all platforms.
|
||||
* <inttypes.h> should define these but this is not true all platforms.
|
||||
* (for example win32) */
|
||||
#ifndef SDL_PRIs64
|
||||
#if defined(SDL_PLATFORM_WINDOWS)
|
||||
|
@ -482,6 +501,25 @@ typedef Sint64 SDL_Time;
|
|||
#define SDL_PRIX32 "X"
|
||||
#endif
|
||||
#endif
|
||||
/* Specifically for the `long long` -- SDL-specific. */
|
||||
#ifndef SDL_PLATFORM_WINDOWS
|
||||
#define SDL_PRILL_PREFIX "ll"
|
||||
#else
|
||||
SDL_COMPILE_TIME_ASSERT(longlong_size64, sizeof(long long) == 8); /* using I64 for windows - make sure `long long` is 64 bits. */
|
||||
#define SDL_PRILL_PREFIX "I64"
|
||||
#endif
|
||||
#ifndef SDL_PRILLd
|
||||
#define SDL_PRILLd SDL_PRILL_PREFIX "d"
|
||||
#endif
|
||||
#ifndef SDL_PRILLu
|
||||
#define SDL_PRILLu SDL_PRILL_PREFIX "u"
|
||||
#endif
|
||||
#ifndef SDL_PRILLx
|
||||
#define SDL_PRILLx SDL_PRILL_PREFIX "x"
|
||||
#endif
|
||||
#ifndef SDL_PRILLX
|
||||
#define SDL_PRILLX SDL_PRILL_PREFIX "X"
|
||||
#endif
|
||||
|
||||
/* Annotations to help code analysis tools */
|
||||
#ifdef SDL_DISABLE_ANALYZE_MACROS
|
||||
|
@ -539,25 +577,6 @@ typedef Sint64 SDL_Time;
|
|||
#endif
|
||||
#endif /* SDL_DISABLE_ANALYZE_MACROS */
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
#if defined(__cplusplus)
|
||||
/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */
|
||||
#if (__cplusplus >= 201103L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||
#endif
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||
#endif
|
||||
#endif /* !SDL_COMPILE_TIME_ASSERT */
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
/* universal, but may trigger -Wunused-local-typedefs */
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
|
||||
#endif
|
||||
|
||||
/** \cond */
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
SDL_COMPILE_TIME_ASSERT(bool_size, sizeof(bool) == 1);
|
||||
|
|
|
@ -714,15 +714,8 @@ static int SDLCALL stdlib_getsetenv(void *arg)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SDL_PLATFORM_WINDOWS
|
||||
#define FMT_PRILLd "%lld"
|
||||
#define FMT_PRILLu "%llu"
|
||||
#else
|
||||
/* make sure long long is 64 bits */
|
||||
SDL_COMPILE_TIME_ASSERT(longlong_size64, sizeof(long long) == 8);
|
||||
#define FMT_PRILLd "%I64d"
|
||||
#define FMT_PRILLu "%I64u"
|
||||
#endif
|
||||
#define FMT_PRILLd "%" SDL_PRILLd
|
||||
#define FMT_PRILLu "%" SDL_PRILLu
|
||||
|
||||
/**
|
||||
* Call to SDL_sscanf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue