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 --- configure.ac | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 91bd898c..6d4f3081 100644 --- a/configure.ac +++ b/configure.ac @@ -448,24 +448,31 @@ $ac_cv_sizeof_int) dbusint64=int dbusint64_constant='(val)' dbusuint64_constant='(val)' + dbusint64_modifier="" ;; $ac_cv_sizeof_long) dbusint64=long dbusint64_constant='(val##L)' dbusuint64_constant='(val##UL)' + dbusint64_modifier="l" ;; $ac_cv_sizeof_long_long) dbusint64='long long' dbusint64_constant='(val##LL)' dbusuint64_constant='(val##ULL)' + dbusint64_modifier="ll" ;; $ac_cv_sizeof___int64) dbusint64=__int64 dbusint64_constant='(val##i64)' dbusuint64_constant='(val##ui64)' + dbusint64_modifier="I64" ;; esac +# MSVCRT.dll printf() doesn't support %lld +AS_IF([test "$dbus_win" = yes], [dbusint64_modifier="I64"]) + AS_IF( [test -z "$dbusint64"], [AC_MSG_RESULT([not found]) @@ -480,12 +487,14 @@ Please report a bug here with details of your platform and compiler: DBUS_INT64_TYPE="$dbusint64" DBUS_INT64_CONSTANT="$dbusint64_constant" DBUS_UINT64_CONSTANT="$dbusuint64_constant" + DBUS_INT64_MODIFIER="$dbusint64_modifier" AC_MSG_RESULT($DBUS_INT64_TYPE) ]) AC_SUBST(DBUS_INT64_TYPE) AC_SUBST(DBUS_INT64_CONSTANT) AC_SUBST(DBUS_UINT64_CONSTANT) +AC_SUBST(DBUS_INT64_MODIFIER) ### see what 32-bit int is called AC_MSG_CHECKING([32-bit integer type]) -- cgit v1.2.1