Fix MSVC compilation error in user/tests/input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In dlls/user/tests/input.c we use the INPUT structure which has an
unnamed union. So we set NONAMELESSUNION (and NONAMELESSSTRUCT for some
reason), so that it will be named (for a broad compiler compatibility).

However the MSVC headers ignore our request and leave it unnamed anyway!
So our code does not compile with MSVC.

Since we use this union in just one place, I have redefined the type in
the test and I have named the struct. This way we know it will compile
whatever happens. Anyone feel free to suggest a better solution.

Changelog:

 * dlls/user/tests/input.c

   The MSVC headers won't give a name to the nameless union of INPUT
despite our request (NONAMELESSUNION). So define our own type and use it
instead.
   Remove useless NONAMELESSSTRUCT.
   Fix signed/unsigned warning.


Index: dlls/user/tests/input.c
===================================================================
RCS file: /home/cvs/wine/dlls/user/tests/input.c,v
retrieving revision 1.2
diff -u -r1.2 input.c
--- dlls/user/tests/input.c	28 Oct 2003 21:45:31 -0000	1.2
+++ dlls/user/tests/input.c	15 Jan 2004 12:05:22 -0000
@@ -44,11 +44,8 @@
  *
  */

-/* for definitions of INPUT */
 #define _WIN32_WINNT 0x401

-#define NONAMELESSUNION
-#define NONAMELESSSTRUCT
 #include "wine/test.h"
 #include "winbase.h"
 #include "winuser.h"
@@ -79,13 +76,25 @@
 /* matching descripts */
 char *getdesc[]={"", "+alt","-alt","+X","-X","+shift","-shift","+ctrl","-ctrl"};

+/* The MSVC headers ignore our NONAMELESSUNION requests so we have to define our own type */
+typedef struct
+{
+    DWORD type;
+    union
+    {
+        MOUSEINPUT      mi;
+        KEYBDINPUT      ki;
+        HARDWAREINPUT   hi;
+    } u;
+} TEST_INPUT;
+
 #define ADDTOINPUTS(kev) \
 inputs[evtctr].type = INPUT_KEYBOARD; \
-    inputs[evtctr].u.ki.wVk = GETVKEY[ kev]; \
-    inputs[evtctr].u.ki.wScan = GETSCAN[ kev]; \
-    inputs[evtctr].u.ki.dwFlags = GETUPDOWN[ kev]; \
-    inputs[evtctr].u.ki.dwExtraInfo = 0; \
-    inputs[evtctr].u.ki.time = ++timetag; \
+    ((TEST_INPUT*)inputs)[evtctr].u.ki.wVk = GETVKEY[ kev]; \
+    ((TEST_INPUT*)inputs)[evtctr].u.ki.wScan = GETSCAN[ kev]; \
+    ((TEST_INPUT*)inputs)[evtctr].u.ki.dwFlags = GETUPDOWN[ kev]; \
+    ((TEST_INPUT*)inputs)[evtctr].u.ki.dwExtraInfo = 0; \
+    ((TEST_INPUT*)inputs)[evtctr].u.ki.time = ++timetag; \
     if( kev) evtctr++;

 typedef struct {
@@ -198,7 +207,8 @@
     KMSG expmsg[MAXKEYEVENTS];
     MSG msg;
     char buf[100];
-    int evtctr=0, kmctr, i;
+    UINT evtctr=0;
+    int kmctr, i;
     buf[0]='\0';
     TrackSysKey=0; /* see input.c */
     for( i = 0; i < MAXKEYEVENTS; i++) {



-- 
Francois Gouget         fgouget@xxxxxxx        http://fgouget.free.fr/
    Indifference will certainly be the downfall of mankind, but who cares?


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux