diff --git a/gc_heap.c b/gc_heap.c index 0b47505a..b91c5281 100644 --- a/gc_heap.c +++ b/gc_heap.c @@ -635,7 +635,7 @@ sexp sexp_load_image (const char* filename, off_t offset, sexp_uint_t heap_free_ goto done; } if (offset > 0 && fseek(fp, offset, SEEK_SET) < 0) { - snprintf(gc_heap_err_str, ERR_STR_SIZE, "couldn't seek to image offset: %s -> "PRIoff": %s\n", filename, offset, strerror(errno)); + snprintf(gc_heap_err_str, ERR_STR_SIZE, "couldn't seek to image offset: %s -> %"SEXP_PRIdOFF": %s\n", filename, offset, strerror(errno)); goto done; } diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 1a97c683..151427f1 100644 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -283,9 +283,20 @@ typedef short sexp_int32_t; #endif #if defined(__APPLE__) || defined(_WIN64) || (defined(__CYGWIN__) && __SIZEOF_POINTER__ == 8) -#define PRIoff "%lld" +#define SEXP_PRIdOFF "lld" #else -#define PRIoff "%ld" +#define SEXP_PRIdOFF "ld" +#endif + +#if defined(__GNUC__) || defined(_WIN64) || defined(__APPLE__) +#include +#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 diff --git a/sexp.c b/sexp.c index 68bc6235..d4d2b998 100644 --- a/sexp.c +++ b/sexp.c @@ -2111,7 +2111,7 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) { break; } } else if (sexp_fixnump(obj)) { - snprintf(numbuf, NUMBUF_LEN, "%ld", (long)sexp_unbox_fixnum(obj)); + snprintf(numbuf, NUMBUF_LEN, "%" SEXP_PRIdFIXNUM, (long)sexp_unbox_fixnum(obj)); sexp_write_string(ctx, numbuf, out); #if SEXP_USE_IMMEDIATE_FLONUMS } else if (sexp_flonump(obj)) {