Avoid compiler warning about mismatched printf types

Under Unix with SEXP_64_BIT defined, sexp_sint_t is defined as 'long'.
But we would get the equivalent format specifier SEXP_PRIdFIXNUM from
the OS-defined PRId64 in <inttypes.h>. MacOS defines it as "lld". This
causes the clang printf checker to emit a warning about the 'long' and
'long long' mismatch.

Fix by avoiding system-defined PRId32 and PRId64 format specifiers and
always defining SEXP_PRIdFIXNUM as "d", "ld" or "lld" according to our
definition of sexp_sint_t as int, long or long long. This also means
we don't need to include <inttypes.h> any more.
This commit is contained in:
Lassi Kortela 2019-04-24 12:26:01 +03:00
parent 105a4672e7
commit 2dc4353604

View file

@ -215,10 +215,12 @@ enum sexp_types {
typedef unsigned int sexp_tag_t; typedef unsigned int sexp_tag_t;
typedef unsigned long long sexp_uint_t; typedef unsigned long long sexp_uint_t;
typedef long long sexp_sint_t; typedef long long sexp_sint_t;
#define SEXP_PRIdFIXNUM "lld"
#else #else
typedef unsigned short sexp_tag_t; typedef unsigned short sexp_tag_t;
typedef unsigned int sexp_uint_t; typedef unsigned int sexp_uint_t;
typedef int sexp_sint_t; typedef int sexp_sint_t;
#define SEXP_PRIdFIXNUM "d"
#endif #endif
#define sexp_heap_align(n) sexp_align(n, 5) #define sexp_heap_align(n) sexp_align(n, 5)
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>5) #define sexp_heap_chunks(n) (sexp_heap_align(n)>>5)
@ -226,18 +228,21 @@ typedef int sexp_sint_t;
typedef unsigned int sexp_tag_t; typedef unsigned int sexp_tag_t;
typedef unsigned long sexp_uint_t; typedef unsigned long sexp_uint_t;
typedef long sexp_sint_t; typedef long sexp_sint_t;
#define SEXP_PRIdFIXNUM "ld"
#define sexp_heap_align(n) sexp_align(n, 5) #define sexp_heap_align(n) sexp_align(n, 5)
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>5) #define sexp_heap_chunks(n) (sexp_heap_align(n)>>5)
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
typedef unsigned short sexp_tag_t; typedef unsigned short sexp_tag_t;
typedef unsigned int sexp_uint_t; typedef unsigned int sexp_uint_t;
typedef int sexp_sint_t; typedef int sexp_sint_t;
#define SEXP_PRIdFIXNUM "d"
#define sexp_heap_align(n) sexp_align(n, 5) #define sexp_heap_align(n) sexp_align(n, 5)
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>5) #define sexp_heap_chunks(n) (sexp_heap_align(n)>>5)
#else #else
typedef unsigned short sexp_tag_t; typedef unsigned short sexp_tag_t;
typedef unsigned int sexp_uint_t; typedef unsigned int sexp_uint_t;
typedef int sexp_sint_t; typedef int sexp_sint_t;
#define SEXP_PRIdFIXNUM "d"
#define sexp_heap_align(n) sexp_align(n, 4) #define sexp_heap_align(n) sexp_align(n, 4)
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>4) #define sexp_heap_chunks(n) (sexp_heap_align(n)>>4)
#endif #endif
@ -290,17 +295,6 @@ typedef short sexp_int32_t;
#define SEXP_PRIdOFF "ld" #define SEXP_PRIdOFF "ld"
#endif #endif
#if SEXP_USE_INTTYPES
#include <inttypes.h>
#if SEXP_64_BIT
#define SEXP_PRIdFIXNUM PRId64
#else
#define SEXP_PRIdFIXNUM PRId32
#endif
#else
#define SEXP_PRIdFIXNUM "ld"
#endif
#if SEXP_USE_LONG_PROCEDURE_ARGS #if SEXP_USE_LONG_PROCEDURE_ARGS
typedef int sexp_proc_num_args_t; typedef int sexp_proc_num_args_t;
#else #else