From 6130ac4267842a6d3851ff4c1d8480532a2ba8cd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Apr 2022 15:57:07 +0100 Subject: 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 --- bus/containers.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'bus') diff --git a/bus/containers.c b/bus/containers.c index 8abeca1f..1a95a4a5 100644 --- a/bus/containers.c +++ b/bus/containers.c @@ -414,10 +414,8 @@ bus_container_instance_new (BusContext *context, goto fail; } - /* We assume PRIu64 exists on all Unix platforms: it's ISO C99, and the - * only non-C99 platform we support is MSVC on Windows. */ if (!_dbus_string_append_printf (&path, - "/org/freedesktop/DBus/Containers1/c%" PRIu64, + "/org/freedesktop/DBus/Containers1/c%" DBUS_INT64_MODIFIER "u", containers->next_container_id++)) { BUS_SET_OOM (error); -- cgit v1.2.1