commit 1b9711497fb9caf525bd513abbe64bc2eb34963c
parent 4967f15fd57f7e48ae5f3bd749ee6665ebdafb9d
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date: Sat, 6 Nov 2021 22:23:36 -0700
Use a compile test for time_t format specifier
Diffstat:
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -176,14 +176,22 @@ AC_MSG_RESULT([$env_cygwin])
AM_CONDITIONAL(CYGWIN, test x"$env_cygwin" = x"yes")
AC_MSG_CHECKING([for time_t format specifier])
-case "$host" in
- x86_64-w64-mingw32)
- time_t_fmt=lld
- ;;
- *)
- time_t_fmt=ld
- ;;
-esac
+_gcc_cflags_save=$CFLAGS
+CFLAGS="-Wall -Werror"
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ #include <stdio.h>
+ #include <time.h>
+ ]],[[printf("%lld", time(NULL));]])],
+ [time_t_long_long=yes],
+ [time_t_long_long=no])
+CFLAGS=$_gcc_cflags_save
+
+if test x"$time_t_long_long" = xyes; then
+ time_t_fmt=lld
+else
+ time_t_fmt=ld
+fi
AC_MSG_RESULT([$time_t_fmt])
AC_DEFINE_UNQUOTED([CM_TIME_FORMAT], ["$time_t_fmt"],
[Define printf format specifier for time_t])