[m-rev.] diff: fix problem with float64_bits_string/1 on Windows

Julien Fischer jfischer at opturion.com
Wed May 1 15:58:15 AEST 2013


Fix problem with float64_bits_string/1 on Windows.

library/float.m:
      Some of the C compilers on Windows (MSVC and some versions of 32-bit
      MinGW GCC) do not support the "ll" size prefix in conversion
      specifiers.  In this case, use an extension to the Microsoft
      C library that provides equivalent functionality.
      (Annoyingly, only the Cygwin GCC raised a warning about this,
      everything else just silently did the wrong thing!)

Julien.

diff --git a/library/float.m b/library/float.m
index cfb28dd..9f44591 100644
--- a/library/float.m
+++ b/library/float.m
@@ -943,6 +943,14 @@ float.float_to_doc(X) = str(string.float_to_string(X)).
      u.f = (double) Flt;
      #if defined(MR_MINGW64) || defined(MR_CYGWIN)
          sprintf(buf, ""%lld"", u.i);
+    #elif defined(MR_WIN32)
+        /*
+        ** The I64 size prefix is specific to the Microsoft
+        ** C library -- we use it here since MSVC and (some)
+        ** versions of 32-bit MinGW GCC do not support the
+        ** standard ll size prefix.
+        */
+        sprintf(buf, ""%I64d"", u.i);
      #else
          sprintf(buf, ""%ld"", u.i);
      #endif



More information about the reviews mailing list