int64_t vs gint64 mismatch
Hi.
I just found an issue with integer types with GLib and OpenBSD. On OpenBSD, int64_t is always "signed long long" whatever the architecture. "signed long" is 64-bit on our 64-bit architectures and the problem is that GLib configure script check will match ac_cv_sizeof_long and we'll end up with the following in glibconfig.h (sizeof(long) == sizeof(int64_t) on 64-bit): typedef signed long gint64;
In theory that would not be an issue except with C++ code where is blows up (it would require casting all over the place since there's a mismatch definition; gint64 != int64_t).
Sample case: https://bugs.gnucash.org/show_bug.cgi?id=796749
So far I am testing the following patch [1] which seems to work fine. I don't want to open a MR (it misses the meson part anyway) because I'd like to have your input on this or see if we could come up with a better solution to check the different types on an OS. Hope this make sense :-)
[1]
Index: configure.ac
--- configure.ac.orig
+++ configure.ac
@@ -3106,13 +3106,26 @@ $ac_cv_sizeof_int)
guint64_constant='(val)'
;;
$ac_cv_sizeof_long)
- gint64=long
- gint64_modifier='"l"'
- gint64_format='"li"'
- guint64_format='"lu"'
- glib_extension=
- gint64_constant='(val##L)'
- guint64_constant='(val##UL)'
+ case $host in
+ *-*-openbsd*)
+ gint64='long long'
+ gint64_modifier='"ll"'
+ gint64_format='"lli"'
+ guint64_format='"llu"'
+ glib_extension=
+ gint64_constant='(val##LL)'
+ guint64_constant='(val##ULL)'
+ ;;
+ *)
+ gint64=long
+ gint64_modifier='"l"'
+ gint64_format='"li"'
+ guint64_format='"lu"'
+ glib_extension=
+ gint64_constant='(val##L)'
+ guint64_constant='(val##UL)'
+ ;;
+ esac
;;
$ac_cv_sizeof_long_long)
gint64='long long'
@@ -3349,7 +3362,14 @@ $ac_cv_sizeof_int)
gint64=int
;;
$ac_cv_sizeof_long)
- gint64=long
+ case $host in
+ *-*-openbsd*)
+ gint64='long long'
+ ;;
+ *)
+ gint64=long
+ ;;
+ esac
;;
$ac_cv_sizeof_long_long)
gint64='long long'