diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2019-08-03 16:14:22 +0200 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2019-08-03 16:24:04 +0200 |
commit | 40f1cf8aa72185cce0994aaaf8b14d524e5a4d8b (patch) | |
tree | a2d1d376142e73a15dda2e2dcaa32c40d818f778 /netdissect-stdinc.h | |
parent | 64ab4a9e04c8f92871a9c3a89b91ddf3498741c3 (diff) | |
download | tcpdump-40f1cf8aa72185cce0994aaaf8b14d524e5a4d8b.tar.gz |
Add PRIsize, to use as the print format for size_t
size_t may be bigger than unsigned long, so don't just cast to unsigned
long and print with %lu". (In practice, the value is unlikely to be
bigger, but this is cleaner.)
We could use %zu on UN*X, as we require C99 support and C99 requires
support for z as a size modifier, but MSVC doesn't support z as a size
modifier until Visual Studio 2017.
Updated from:
libpcap/commit/e217f88289b9601e3a9a8d13477f867bcb83b5e2
Diffstat (limited to 'netdissect-stdinc.h')
-rw-r--r-- | netdissect-stdinc.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h index 5aef8234..9cf3cf07 100644 --- a/netdissect-stdinc.h +++ b/netdissect-stdinc.h @@ -148,12 +148,23 @@ #define PRIu64 "llu" #endif #endif + + /* + * MSVC's support library doesn't support %zu to print a size_t until + * Visual Studio 2017, but supports %Iu earlier, so use that. + */ + #define PRIsize "Iu" #elif defined(__MINGW32__) || !defined(_WIN32) /* * Compiler is MinGW or target is UN*X or MS-DOS. Just use * <inttypes.h>. */ #include <inttypes.h> + + /* + * Assume the support library supports %zu; it's required by C99. + */ + #define PRIsize "zu" #endif #endif /* HAVE_PCAP_PCAP_INTTYPES_H */ |