aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-10-15 22:47:35 +0200
committerJay Berkenbilt <ejb@ql.org>2020-10-16 13:02:23 +0200
commitff65e272a8f8e647a3db5187e5c4594ff01cbd34 (patch)
treecb86bf74c0b5c6d1d1f49a3dbcf519ac4fe3cbe2 /configure.ac
parentbe21ede7ba05027829adaf7275e9bbbc1574a760 (diff)
downloadqpdf-ff65e272a8f8e647a3db5187e5c4594ff01cbd34.tar.zst
Fix printf formatting for newer msvc
Use autoconf rather than ifdefs to determine what format string to use for long long.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac33
1 files changed, 33 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 3e91ae19..83587b82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -505,6 +505,39 @@ if test "$BUILDRULES" != "msvc"; then
fi
fi
+LL_FMT=""
+oCFLAGS=$CFLAGS
+CFLAGS="$WFLAGS $CFLAGS"
+for fmt in "%lld" "%I64d" "%I64lld"; do
+ if test "$LL_FMT" = ""; then
+ AC_MSG_CHECKING(printf format for long long: $fmt)
+ AC_RUN_IFELSE([AC_LANG_PROGRAM(
+ [[
+ #define _CRT_SECURE_NO_WARNINGS
+ #include <stdio.h>
+ #include <string.h>
+ ]],
+ [[
+ long long int a = 123456789012345ll;
+ char s[30];
+ sprintf(s, "]$fmt[", a);
+ return (strcmp(s, "123456789012345") == 0) ? 0 : 1
+ ]]
+ )],
+ [LL_FMT=$fmt],[],[LL_FMT="%lld"])
+ if test "$LL_FMT" != ""; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ fi
+done
+CFLAGS=$oCFLAGS
+if test "LL_FMT" = ""; then
+ LL_FMT="%lld%"
+fi
+AC_DEFINE_UNQUOTED([LL_FMT], ["$LL_FMT"], [printf format for long long])
+
AC_SUBST(WINDOWS_WMAIN_XLINK_FLAGS)
AC_SUBST(WINDOWS_MAIN_XLINK_FLAGS)
if test "$BUILDRULES" = "msvc"; then