aboutsummaryrefslogtreecommitdiffstats
path: root/unpack.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-08-05 20:10:07 +0100
committerTomasz Kramkowski <tk@the-tk.com>2021-08-05 20:13:07 +0100
commit7e7bdc19e76a5f87bccf7a84872f8d45295ee5b7 (patch)
tree226c43176517f7f3dc30e3d67862449cef0c7d16 /unpack.c
parent07ed3ac992d5086dcd47273236ad72e496d9620f (diff)
downloadpack-7e7bdc19e76a5f87bccf7a84872f8d45295ee5b7.tar.gz
pack-7e7bdc19e76a5f87bccf7a84872f8d45295ee5b7.tar.xz
pack-7e7bdc19e76a5f87bccf7a84872f8d45295ee5b7.zip
Define PRIuSIZE to avoid issues compiling with msvcrt
On windows and when cross compiling with mingw the standard library only supports C89 which means that print format arguments cannot take "%zu". To fix this, a PRIuSIZE macros is needed which expands to PRIu32 on windows 32 bit and PRIu64 on windows 64 bit.
Diffstat (limited to 'unpack.c')
-rw-r--r--unpack.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/unpack.c b/unpack.c
index 1686cd7..6c0d97d 100644
--- a/unpack.c
+++ b/unpack.c
@@ -43,7 +43,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
size_t offset = 0;
va_list ap;
- tr_call("unpack(%p, %zu, %s, ...)", (const void *)buf, size, fmt);
+ tr_call("unpack(%p, %" PRIuSIZE ", %s, ...)", (const void *)buf, size, fmt);
va_start(ap, fmt);
@@ -81,7 +81,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
i++;
}
sign = islower(fmt[i]);
- tr_debug("count: %zu, i: %d, fmt[i]: %c, sign: %ssigned",
+ tr_debug("count: %" PRIuSIZE ", i: %d, fmt[i]: %c, sign: %ssigned",
count, i, fmt[i], sign ? "" : "un");
switch (fmt[i]) {
case '>': endianness = BIG; continue;
@@ -103,7 +103,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
}
s = getsize(fmt[i]);
- tr_debug("s: %zu", s);
+ tr_debug("s: %" PRIuSIZE, s);
if (s == (size_t)-1) return PACK_FMTINVAL;
if (size - offset < s * count) return PACK_TOOSMALL;
@@ -112,7 +112,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
for (size_t j = 0; j < count; j++) {
val.u = read_val(buf + offset + s * j, s, endianness);
- tr_debug("val.u: %" PRIuMAX ", at: %zu", val.u, offset + s * j);
+ tr_debug("val.u: %" PRIuMAX ", at: %" PRIuSIZE, val.u, offset + s * j);
if (fmt[i] == 'f') {
float f = ieee754b32_deserialise(val.u);