<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] init warning



Hi,

* David Champion wrote:
I hope I'm misremembering, but I'm pretty sure this is why you see a
fair amount of code that takes pains to use macros for its integer
formatters.

I found out about these, too. However, I think we should provide a fallback since it's IHMO not worth it to require C99 compatible compilers just for a few printf statements being part of large file support.

Using the current code as fallback together with the SIZEOF_LONG==4 check, the attached patch only leaves me with warnings about format modifiers not being C90 compatible but without argument size warnings in 32bit and 64bit compilation mode. This seems to be much better than cast to the type we think is right and disallow the compiler to warn us we're wrong.

Does mutt support < C99?  I don't remember.

Yes, it more or less even "requires" it since it adds -pedantic to the arguments when configure detects gcc as compiler.

Rocco
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -88,10 +88,18 @@ AH_BOTTOM([/* fseeko portability defines
 AH_BOTTOM([/* fseeko portability defines */
 #ifdef HAVE_FSEEKO
 # define LOFF_T off_t
-# if SIZEOF_OFF_T == 8
-#  define OFF_T_FMT "%lld"
+# if HAVE_C99_INTTYPES
+#  if SIZEOF_OFF_T == 8
+#   define OFF_T_FMT "%" PRId64
+#  else
+#   define OFF_T_FMT "%" PRId32
+#  endif
 # else
-#  define OFF_T_FMT "%ld"
+#  if (SIZEOF_OFF_T == 8) && (SIZEOF_LONG == 4)
+#   define OFF_T_FMT "%lld"
+#  else
+#   define OFF_T_FMT "%ld"
+#  endif
 # endif
 #else
 # define LOFF_T long
diff --git a/m4/types.m4 b/m4/types.m4
--- a/m4/types.m4
+++ b/m4/types.m4
@@ -10,11 +10,11 @@ AC_DEFUN([MUTT_C99_INTTYPES],
 [dnl
 AC_CHECK_HEADERS([inttypes.h])
 AC_CHECK_TYPE([uint32_t],
-  [AC_DEFINE(HAVE_C99_INTTYPES, 1, [Define if you have the C99 integer 
types])],
-  [AC_CHECK_SIZEOF(short)
-   AC_CHECK_SIZEOF(int)
-   AC_CHECK_SIZEOF(long)
-   AC_CHECK_SIZEOF(long long)])
+  [AC_DEFINE(HAVE_C99_INTTYPES, 1, [Define if you have the C99 integer 
types])])
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)])
 AH_VERBATIM([X_HAVE_C99_INTTYPES],
   [#ifndef HAVE_C99_INTTYPES
 #  if SIZEOF_SHORT == 4
@@ -33,4 +33,3 @@ typedef unsigned long long uint64_t;
 #  endif
 #endif
   ])
-])