[m-rev.] diff: avoid compiler warnings from MSVC

Julien Fischer jfischer at opturion.com
Tue Jan 28 17:29:06 AEDT 2014


Avoid compiler warnings from MSVC in generated code.

runtime/mercury_float.h:
 	Avoid warnings from MSVC about the types of the formal and actual parameters
 	of calls to MR_float_from_dword differing.  The formal parameters have type
 	MR_Word, but the Mercury compiler doesn't emit casts for the arguments.
 	(For GCC and clang, MR_float_from_dword is defined as a macro and the
 	necessary casts occur in its body.)  The fix is to rename the function
 	version of MR_float_from_dword and make MR_float_from_dword a forwarding macro
 	that inserts the necessary casts.

Julien.

diff --git a/runtime/mercury_float.h b/runtime/mercury_float.h
index b302f80..9009593 100644
--- a/runtime/mercury_float.h
+++ b/runtime/mercury_float.h
@@ -137,11 +137,15 @@
          __ffdw.f;                                                           \
        })
    #else
+
+    #define MR_float_from_dword(w0, w1)				 	    \
+	MR_float_from_dword_func((MR_Word)(w0), (MR_Word)(w1))
+
      MR_EXTERN_INLINE MR_Float
-    MR_float_from_dword(MR_Word w0, MR_Word w1);
+    MR_float_from_dword_func(MR_Word w0, MR_Word w1);

      MR_EXTERN_INLINE MR_Float
-    MR_float_from_dword(MR_Word w0, MR_Word w1)
+    MR_float_from_dword_func(MR_Word w0, MR_Word w1)
      {
          union MR_Float_Dword __ffdw;
          __ffdw.w[0] = (MR_Word) (w0);





More information about the reviews mailing list