Fix vartype.c MSVC compilation errors

Francois Gouget fgouget at free.fr
Wed Sep 1 21:59:50 CDT 2004


vartype.c casts some unsigned int 64 integers to floats which Visual C++
6.0 does not implement, thus leading to the following compilation error:

error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64


The solution is to install the Visual Studio "processor pack".
Unfortunately that processor pack is incompatible with the Standard
Edition of Visual Studio which is what I have :-(
It's also incompatible with the Service Pack 6 which is the latest
Visual Studio service pack and might be annoying to other people.

So I tweaked the vartype.c test to #ifdef-out the tests that involve
these conversions if Visual Studio does not support them. The patch
should even detect whether the "processor pack" is installed or not
although I could obviously not test that.

Actually the patch disables out a bit more than is strictly necessary
because the INITIAL_TYPETEST() and COMMON_TYPETEST macros actually
expand to a ton of tests, one of which happens to be the troublesome
tests, but there is no way to disable just one of them in just some
cases. But there's still lots of tests left and is much better than not
being able to compile anything.


Changelog:

 * dlls/oleaut32/tests/vartype.c

   Detect whether Visual Studio can cast __uint64's to floats and
disable the relevant tests if it cannot.
   Fix a double to float literal conversion warning.

-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
  Any sufficiently advanced Operating System is indistinguishable from Linux
-------------- next part --------------
Index: dlls/oleaut32/tests/vartype.c
===================================================================
RCS file: /var/cvs/wine/dlls/oleaut32/tests/vartype.c,v
retrieving revision 1.16
diff -u -r1.16 vartype.c
--- dlls/oleaut32/tests/vartype.c	25 Aug 2004 00:38:59 -0000	1.16
+++ dlls/oleaut32/tests/vartype.c	1 Sep 2004 13:16:30 -0000
@@ -23,6 +23,25 @@
 #include "oleauto.h"
 #include <math.h>
 
+/* Some Visual C++ versions choke on __uint64 to float conversions.
+ * To fix this you need either VC++ 6.0 plus the processor pack
+ * or Visual C++ >=7.0.
+ */
+#ifndef _MSC_VER
+#  define HAS_UINT64_TO_FLOAT
+#else
+#  if _MSC_VER >= 1300
+#    define HAS_UINT64_TO_FLOAT
+#  else
+#    include <malloc.h>
+#    if defined(_mm_free)
+/*     _mm_free is defined if the Processor Pack has been installed */
+#      define HAS_UINT64_TO_FLOAT
+#    endif
+
+#  endif
+#endif
+
 static HMODULE hOleaut32;
 
 #ifdef NONAMELESSUNION
@@ -2765,6 +2784,7 @@
 
 static void test_VarR4ChangeTypeEx(void)
 {
+#ifdef HAS_UINT64_TO_FLOAT
   CONVVARS(CONV_TYPE);
   VARIANTARG vSrc, vDst;
 
@@ -2772,6 +2792,7 @@
 
   INITIAL_TYPETEST(VT_R4, V_R4, "%f");
   COMMON_TYPETEST;
+#endif
 }
 
 /*
@@ -2972,6 +2993,7 @@
 
 static void test_VarR8ChangeTypeEx(void)
 {
+#ifdef HAS_UINT64_TO_FLOAT
   CONVVARS(CONV_TYPE);
   VARIANTARG vSrc, vDst;
 
@@ -2979,6 +3001,7 @@
 
   INITIAL_TYPETEST(VT_R8, V_R8, "%g");
   COMMON_TYPETEST;
+#endif
 }
 
 #define MATHRND(l, r) left = l; right = r; hres = pVarR8Round(left, right, &out)
@@ -3374,8 +3397,10 @@
 
   in = 1.0;
 
+#ifdef HAS_UINT64_TO_FLOAT
   INITIAL_TYPETEST(VT_DATE, V_DATE, "%g");
   COMMON_TYPETEST;
+#endif
 
   V_VT(&vDst) = VT_EMPTY;
   V_VT(&vSrc) = VT_DATE;
@@ -4527,7 +4552,7 @@
   CHECKPTR(VarBstrFromR4);
 
   lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
-  f = 654322.23456,
+  f = 654322.23456f;
   hres = pVarBstrFromR4(f, lcid, 0, &bstr);
   ok(hres == S_OK, "got hres 0x%08lx\n", hres);
   if (bstr)


More information about the wine-patches mailing list