[m-rev.] for review: Fix compilation warning with 32-bit MinGW.

Julien Fischer jfischer at opturion.com
Thu Oct 6 16:22:56 AEDT 2022


On Thu, 6 Oct 2022, Peter Wang wrote:

> I got this warning when cross-compiling for Windows/x86 with
> i686-w64-mingw32-gcc version 11.1.0:
>
>    format '%d' expects argument of type 'int', but argument 3 has type 'MR_int_least64_t'
>
> library/float.m:
>    Use MR_INT_LEAST64_LENGTH_MODIFIER in float64_bits_string
>    except when compiling with MSVC.
>
> diff --git a/library/float.m b/library/float.m
> index 5b65ed142..3ca6e56fe 100644
> --- a/library/float.m
> +++ b/library/float.m
> @@ -1212,12 +1212,10 @@ float_to_doc(X) = str(string.float_to_string(X)).
>         char buf[64];
>
>         u.f = (double) Flt;
> -        #if defined(MR_MINGW64) || defined(MR_CYGWIN32)
> -            sprintf(buf, ""%lld"", u.i);
> -        #elif defined(MR_WIN32)
> +        #if defined(MR_MSVC)
>             // 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.
> +            // -- we use it here since MSVC does not support the standard
> +            // ll size prefix.
>             sprintf(buf, ""%I64d"", u.i);
>         #else
>             sprintf(buf, ""%"" MR_INT_LEAST64_LENGTH_MODIFIER ""d"", u.i);

MSVC has supported the ll prefix since 2013, so I suspect we can
dispense with the special case code for it and just say that we require
MSVC 2013 or later.

Julien.


More information about the reviews mailing list