summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-04-01 15:57:07 +0100
committerSimon McVittie <smcv@collabora.com>2022-04-19 18:27:47 +0000
commit6130ac4267842a6d3851ff4c1d8480532a2ba8cd (patch)
tree317d6487dc2c054a4d3dd26d6bdcfeca06537e91 /tools
parent8972fcb029ca664a948ec9a219ea5b32a8266a33 (diff)
downloaddbus-6130ac4267842a6d3851ff4c1d8480532a2ba8cd.tar.gz
build: Define DBUS_INT64_MODIFIER, analogous to G_GINT64_MODIFIER
Using PRId64, etc. to print dbus_int64_t or dbus_uint64_t is not 100% portable. On platforms where both long and long long are 64-bit (such as Linux and macOS), we will prefer to define dbus_int64_t as long. If the operating system has chosen to define int64_t as long long, which is apparently the case on macOS, then the compiler can warn that we are passing a long argument to PRId64, which is "lld" and therefore expects a long long argument (even though that ends up with the same bit-pattern being used). We can't necessarily just use int64_t and uint64_t directly, even if all our supported platforms have them available now, because swapping dbus_int64_t between long and long long might change C++ name mangling, causing ABI breaks in third-party libraries if they define C++ functions that take a dbus_int64_t argument. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-print-message.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c
index 2ce7f68b..22ee6824 100644
--- a/tools/dbus-print-message.c
+++ b/tools/dbus-print-message.c
@@ -43,15 +43,6 @@
#include <inttypes.h>
#endif
-#if defined(DBUS_WIN)
-#if !defined(PRId64)
-#define PRId64 "I64d"
-#endif
-#if !defined(PRIu64)
-#define PRIu64 "I64u"
-#endif
-#endif
-
#ifndef HAVE_SOCKLEN_T
#define socklen_t int
#endif
@@ -401,7 +392,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
{
dbus_int64_t val;
dbus_message_iter_get_basic (iter, &val);
- printf ("int64 %" PRId64 "\n", val);
+ printf ("int64 %" DBUS_INT64_MODIFIER "d\n", val);
break;
}
@@ -409,7 +400,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
{
dbus_uint64_t val;
dbus_message_iter_get_basic (iter, &val);
- printf ("uint64 %" PRIu64 "\n", val);
+ printf ("uint64 %" DBUS_INT64_MODIFIER "u\n", val);
break;
}