Windows build broken
Trying to build the current CVS Head with Mingw under windows, the result is the following error message:
In file included from tap-win32.c:31:
sysemu.h:125: error: syntax error before ';' token sysemu.h:137: error: syntax error before ',' token sysemu.h:138: error: syntax error before ')' token
make: *** [tap-win32.o] Error 1
__________________________________________________________
Sent from Yahoo! - the World's favourite mail http://uk.mail.yahoo.com
Same problem with cygwin. I think it's a problem with BlockInterfaceType not being correctly parsed on mingw-gcc for some odd reason. ----- Original Message -----
From: "Balazs Attila-Mihaly (Cd-MaN)" <[email protected]>
To: "Qemu Devel" <[email protected]>
Sent: Tuesday, December 11, 2007 8:05 PM
Subject: [Qemu-devel] Windows build broken
Trying to build the current CVS Head with Mingw under windows, the result is the following error message:
In file included from tap-win32.c:31:
sysemu.h:125: error: syntax error before ';' token sysemu.h:137: error: syntax error before ',' token sysemu.h:138: error: syntax error before ')' token
make: *** [tap-win32.o] Error 1
__________________________________________________________
Sent from Yahoo! - the World's favourite mail http://uk.mail.yahoo.com
2007/12/12, C.W. Betts <[email protected]>:
Quoted 3 lines
Same problem with cygwin. I think it's a problem with BlockInterfaceType not being correctly parsed on mingw-gcc for some odd reason.
Hi,
I don't think it is related with BlockInterfaceType itself. The problem is to use "interface" as a variable or parameter name, which seems to be confused with a reserved keyword, type or something like that. I was able to compile with mingw changing that variable name and all its references along the code.
Regards.
Could you perhaps give a patch? I don't feel like going through and changing every instance of BlockInterfaceType to something else.
----- Original Message -----
From: Eduardo Felipe
To: [email protected]
Sent: Wednesday, December 12, 2007 3:41 AM
Subject: Re: [Qemu-devel] Windows build broken
2007/12/12, C.W. Betts <[email protected]>:
Same problem with cygwin. I think it's a problem with BlockInterfaceType not being correctly parsed on mingw-gcc for some odd reason.
Hi,
I don't think it is related with BlockInterfaceType itself. The problem is to use "interface" as a variable or parameter name, which seems to be confused with a reserved keyword, type or something like that. I was able to compile with mingw changing that variable name and all its references along the code.
Regards.
2007/12/12, C.W. Betts <[email protected]>:
Quoted 4 lines
Could you perhaps give a patch? I don't feel like going through and
changing every instance of BlockInterfaceType to something else.
Having a closer look I think the underlying problem is a name conflict with a #define in Mingw's header file basetyps.h, so renaming variables looks right to me. Patch attached.
Regards,
*** sysemu.h
--- sysemu.h
sysemu.h +3 -3
@@ -122,7 +122,7 @@typedef struct DriveInfo {BlockDriverState *bdrv; -BlockInterfaceType interface; +BlockInterfaceType binterface;int bus;int unit; }DriveInfo ;
@@ -134,8 +134,8 @@int nb_drives;DriveInfo drives_table[MAX_DRIVES +1 ]; -extern int drive_get_index (BlockInterfaceType interface,int bus,int unit); -extern int drive_get_max_bus (BlockInterfaceType interface); +extern int drive_get_index (BlockInterfaceType binterface,int bus,int unit); +extern int drive_get_max_bus (BlockInterfaceType binterface);/* serial ports */
*** vl.c
--- vl.c
vl.c +18 -18
@@ -4811,14 +4811,14 @@return nb_drives_opt++; } -int drive_get_index (BlockInterfaceType interface,int bus,int unit) +int drive_get_index (BlockInterfaceType binterface,int bus,int unit) {int index;/* seek interface, bus and unit */ for (index =0 ; index < nb_drives; index++) -if (drives_table[index].interface == interface && +if (drives_table[index].binterface == binterface && drives_table[index].bus == bus && drives_table[index].unit == unit)return index;
@@ -4826,14 +4826,14 @@return -1 ; } -int drive_get_max_bus (BlockInterfaceType interface) +int drive_get_max_bus (BlockInterfaceType binterface) {int max_bus;int index; max_bus =-1 ;for (index =0 ; index < nb_drives; index++) { -if (drives_table[index].interface == interface && +if (drives_table[index].binterface == binterface && drives_table[index].bus > max_bus) max_bus = drives_table[index].bus; }
@@ -4846,7 +4846,7 @@char file[1024 ];char devname[128 ];const char *mediastr ="" ; -BlockInterfaceType interface; +BlockInterfaceType binterface;enum {MEDIA_DISK ,MEDIA_CDROM } media;int bus_id, unit_id;int cyls, heads, secs, translation;
@@ -4875,11 +4875,11 @@ !strcmp(machine->name, "SS-600MP") || !strcmp(machine->name, "versatilepb") || !strcmp(machine->name, "versatileab")) { - interface = IF_SCSI; + binterface = IF_SCSI; max_devs = MAX_SCSI_DEVS; strcpy(devname, "scsi"); } else { - interface =IF_IDE ; + binterface =IF_IDE ; max_devs =MAX_IDE_DEVS ;strcpy (devname,"ide" ); }
@@ -4906,22 +4906,22 @@if (get_param_value (buf,sizeof (buf),"if" , str)) {strncpy (devname, buf,sizeof (devname));if (!strcmp (buf,"ide" )) { - interface =IF_IDE ; + binterface =IF_IDE ; max_devs =MAX_IDE_DEVS ; }else if (!strcmp (buf,"scsi" )) { - interface =IF_SCSI ; + binterface =IF_SCSI ; max_devs =MAX_SCSI_DEVS ; }else if (!strcmp (buf,"floppy" )) { - interface =IF_FLOPPY ; + binterface =IF_FLOPPY ; max_devs =0 ; }else if (!strcmp (buf,"pflash" )) { - interface =IF_PFLASH ; + binterface =IF_PFLASH ; max_devs =0 ; }else if (!strcmp (buf,"mtd" )) { - interface =IF_MTD ; + binterface =IF_MTD ; max_devs =0 ; }else if (!strcmp (buf,"sd" )) { - interface =IF_SD ; + binterface =IF_SD ; max_devs =0 ; }else {fprintf (stderr,"qemu: '%s' unsupported bus type '%s'\n" , str, buf);
@@ -5036,7 +5036,7 @@if (unit_id ==-1 ) { unit_id =0 ; -while (drive_get_index (interface, bus_id, unit_id) !=-1 ) { +while (drive_get_index (binterface, bus_id, unit_id) !=-1 ) { unit_id++;if (max_devs && unit_id >= max_devs) { unit_id -= max_devs;
@@ -5057,23 +5057,23 @@* ignore multiple definitions */ -if (drive_get_index (interface, bus_id, unit_id) !=-1 ) +if (drive_get_index (binterface, bus_id, unit_id) !=-1 )return 0 ;/* init */ -if (interface ==IF_IDE || interface ==IF_SCSI ) +if (binterface ==IF_IDE || binterface ==IF_SCSI ) mediastr = (media ==MEDIA_CDROM ) ?"-cd" :"-hd" ;snprintf (buf,sizeof (buf), max_devs ?"%1$s%4$i%2$s%3$i" :"%s%s%i" , devname, mediastr, unit_id, bus_id); bdrv =bdrv_new (buf); drives_table[nb_drives].bdrv = bdrv; - drives_table[nb_drives].interface = interface; + drives_table[nb_drives].binterface = binterface; drives_table[nb_drives].bus = bus_id; drives_table[nb_drives].unit = unit_id; nb_drives++; -switch (interface) { +switch (binterface) {case IF_IDE :case IF_SCSI :switch (media) {
basetyps.h is included by windows.h / rpc.h. QEMU does not need it, so you can avoid it like this:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
WIN32_LEAN_AND_MEAN reduces the number of includes in windows.h and increases compilation speed. And you don't have to rename variables like interface :-)
Regards,
Stefan
Quoted 175 lines · Eduardo Felipe
2007/12/12, C.W. Betts <[email protected]
<mailto:[email protected]>>:Could you perhaps give a patch? I don't feel like going through and changing every instance of BlockInterfaceType to something else.
Having a closer look I think the underlying problem is a name conflict with a #define in Mingw's header file
basetyps.h, so renaming variables looks right to me. Patch attached.Regards,
------------------------------------------------------------------------
***
sysemu.h
---sysemu.hsysemu.h 12 Dec 2007 19:17:47 -0000 renamed from sysemu.h 2 Dec 2007 04:51:08 -0000 1.2 +3
-3@@ -122,7 +122,7 @@ typedef struct DriveInfo { BlockDriverState *bdrv; - BlockInterfaceType interface; + BlockInterfaceType binterface; int bus; int unit; } DriveInfo;@@ -134,8 +134,8 @@ int nb_drives; DriveInfo drives_table[MAX_DRIVES+1]; -extern int drive_get_index(BlockInterfaceType interface, int bus, int unit); -extern int drive_get_max_bus(BlockInterfaceType interface); +extern int drive_get_index(BlockInterfaceType binterface, int bus, int unit); +extern int drive_get_max_bus(BlockInterfaceType binterface);/* serial ports */
***
vl.c
---vl.cvl.c 12 Dec 2007 19:17:09 -0000 renamed from vl.c 10 Dec 2007 20:00:10 -0000 1.378 +2
-2@@ -4811,14 +4811,14 @@ return nb_drives_opt++; } -int drive_get_index(BlockInterfaceType interface, int bus, int unit) +int drive_get_index(BlockInterfaceType binterface, int bus, int unit) { int index; /* seek interface, bus and unit */ for (index = 0; index < nb_drives; index++) - if (drives_table[index].interface == interface && + if (drives_table[index].binterface == binterface &&drives_table[index].bus == bus &&
drives_table[index].unit == unit)
return index;vl.c 12 Dec 2007 19:17:09 -0000 renamed from vl.c 10 Dec 2007 20:00:10 -0000 1.378 +3
-3@@ -4826,14 +4826,14 @@ return -1; } -int drive_get_max_bus(BlockInterfaceType interface) +int drive_get_max_bus(BlockInterfaceType binterface) { int max_bus; int index; max_bus = -1; for (index = 0; index < nb_drives; index++) { - if(drives_table[index].interface == interface && + if(drives_table[index].binterface == binterface && drives_table[index].bus > max_bus) max_bus = drives_table[index].bus; }@@ -4846,7 +4846,7 @@ char file[1024]; char devname[128]; const char *mediastr = ""; - BlockInterfaceType interface; + BlockInterfaceType binterface; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation;@@ -4875,11 +4875,11 @@!strcmp(machine->name, "SS-600MP") ||
!strcmp(machine->name, "versatilepb") ||
!strcmp(machine->name, "versatileab")) {
- interface =IF_SCSI;
+ binterface =IF_SCSI;max_devs=MAX_SCSI_DEVS;strcpy(devname, "scsi");
} else {
- interface =IF_IDE;
+ binterface =IF_IDE;max_devs=MAX_IDE_DEVS;strcpy(devname, "ide");
}vl.c 12 Dec 2007 19:17:09 -0000 renamed from vl.c 10 Dec 2007 20:00:10 -0000 1.378 +11
-11@@ -4906,22 +4906,22 @@ if (get_param_value(buf, sizeof(buf), "if", str)) { strncpy(devname, buf, sizeof(devname)); if (!strcmp(buf, "ide")) { - interface = IF_IDE; + binterface = IF_IDE; max_devs = MAX_IDE_DEVS; } else if (!strcmp(buf, "scsi")) { - interface = IF_SCSI; + binterface = IF_SCSI; max_devs = MAX_SCSI_DEVS; } else if (!strcmp(buf, "floppy")) { - interface = IF_FLOPPY; + binterface = IF_FLOPPY; max_devs = 0; } else if (!strcmp(buf, "pflash")) { - interface = IF_PFLASH; + binterface = IF_PFLASH; max_devs = 0; } else if (!strcmp(buf, "mtd")) { - interface = IF_MTD; + binterface = IF_MTD; max_devs = 0; } else if (!strcmp(buf, "sd")) { - interface = IF_SD; + binterface = IF_SD; max_devs = 0; } else { fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);@@ -5036,7 +5036,7 @@ if (unit_id == -1) { unit_id = 0; - while (drive_get_index(interface, bus_id, unit_id) != -1) { + while (drive_get_index(binterface, bus_id, unit_id) != -1) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs;@@ -5057,23 +5057,23 @@ * ignore multiple definitions */ - if (drive_get_index(interface, bus_id, unit_id) != -1) + if (drive_get_index(binterface, bus_id, unit_id) != -1) return 0; /* init */ - if (interface == IF_IDE || interface == IF_SCSI) + if (binterface == IF_IDE || binterface == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; snprintf(buf, sizeof(buf), max_devs ? "%1$s%4$i%2$s%3$i" : "%s%s%i", devname, mediastr, unit_id, bus_id); bdrv = bdrv_new(buf); drives_table[nb_drives].bdrv = bdrv; - drives_table[nb_drives].interface = interface; + drives_table[nb_drives].binterface = binterface; drives_table[nb_drives].bus = bus_id; drives_table[nb_drives].unit = unit_id; nb_drives++; - switch(interface) { + switch(binterface) {case
IF_IDE:
caseIF_SCSI:
switch(media) {
Quoted 6 lines · Stefan Weil
basetyps.his included bywindows.h/rpc.h. QEMU does not need it, so you can avoid it like this:#define
WIN32_LEAN_AND_MEAN
#include <windows.h>
Quoted 22 lines
WIN32_LEAN_AND_MEANreduces the number of includes inwindows.hand increases compilation speed. And you don't have to rename variables like interface :-)Regards,
StefanQuoted 14 lines · Eduardo Felipe
2007/12/12, C.W. Betts <[email protected]
<mailto:[email protected]>>:Could you perhaps give a patch? I don't feel like going through and changing every instance of BlockInterfaceType to something else.
Having a closer look I think the underlying problem is a name conflict with a #define in Mingw's header file
basetyps.h, so renaming variables looks right to me. Patch attached.Regards,
Hi,
I would prefer Eduardo's patch, defining WIN32_LEAN_AND_MEAN breaks dsound.
Thanks.
Here is a patch using WIN32_LEAN_AND_MEAN which tries not to break dsound (and vl.c). I could only test it using cross compilation from Linux, so please send comments.
Patch description:
* add WIN32_LEAN_AND_MEAN to all inclusions of windows.h
* remove windows.h from vl.c (it is already included otherwise)
* add mmsystem.h to vl.c and dsoundaudio.c (they need it and got it from windows.h)
* fixed indentation in vl.c (wrong indentation was caused by an earlier patch from me)
It will be difficult to avoid using variable names like "interface" in the future, so I still think using a minimal set of includes is the better (and faster) solution.
Anyway, Windows users need a working solution, so it would be nice if one of these patches could be applied to CVS HEAD.
Thank you.
Stefan
Quoted 14 lines · JonY
Quoted 6 lines · Stefan Weil
basetyps.his included bywindows.h/rpc.h. QEMU does not need it, so you can avoid it like this:#define
WIN32_LEAN_AND_MEAN
#include <windows.h>Quoted 6 lines
WIN32_LEAN_AND_MEANreduces the number of includes inwindows.hand increases compilation speed. And you don't have to rename variables like interface :-)Regards,
Stefan
Quoted 9 lines
Hi,
I would prefer Eduardo's patch, defining
WIN32_LEAN_AND_MEANbreaks dsound.Thanks.
Index: qemu_socket.h
===================================================================
RCS file: /sources/qemu/qemu/qemu_socket.h,v
retrieving revision 1.2
qemu_socket.h +1 -1
@@ -3,7 +3,7 @@#define QEMU_SOCKET_H #ifdef _WIN32 - +#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h>
Index: osdep.c
===================================================================
RCS file: /sources/qemu/qemu/osdep.c,v
retrieving revision 1.20
osdep.c +1 -0
@@ -37,6 +37,7 @@#include "sysemu.h" #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include <windows.h> #elif defined(_BSD)#include <stdlib.h>
Index: vl.c
===================================================================
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.379
vl.c +2 -2
@@ -109,7 +109,7 @@#ifdef _WIN32#include <malloc.h> #include <sys/timeb.h> -#include <windows.h> +#include <mmsystem.h> #define getopt_long_only getopt_long#define memalign (align, size) malloc(size)#endif
@@ -8937,7 +8937,7 @@ s->down_script[0]) launch_script(s->down_script, ifname, s->fd); } - } + } }#endif return 0 ;
Index: tap-win32.c
===================================================================
RCS file: /sources/qemu/qemu/tap-win32.c,v
retrieving revision 1.7
tap-win32.c +1 -0
@@ -30,6 +30,7 @@#include "net.h" #include "sysemu.h" #include <stdio.h> +#define WIN32_LEAN_AND_MEAN #include <windows.h> /* NOTE: PCIBus is redefined in winddk.h */
Index: qemu-common.h
===================================================================
RCS file: /sources/qemu/qemu/qemu-common.h,v
retrieving revision 1.3
qemu-common.h +1 -0
@@ -28,6 +28,7 @@#endif #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include <windows.h> #define fsync _commit#define lseek _lseeki64
Index: exec.c
===================================================================
RCS file: /sources/qemu/qemu/exec.c,v
retrieving revision 1.119
exec.c +1 -0
@@ -19,6 +19,7 @@*/ #include "config.h" #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include <windows.h> #else #include <sys/types.h>
Index: qemu-img.c
===================================================================
RCS file: /sources/qemu/qemu/qemu-img.c,v
retrieving revision 1.25
qemu-img.c +1 -0
@@ -26,6 +26,7 @@#include <assert.h> #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include <windows.h> #endif
Index: kqemu.c
===================================================================
RCS file: /sources/qemu/qemu/kqemu.c,v
retrieving revision 1.19
kqemu.c +1 -0
@@ -19,6 +19,7 @@*/ #include "config.h" #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <winioctl.h> #else
Index: audio/dsoundaudio.c
===================================================================
RCS file: /sources/qemu/qemu/audio/dsoundaudio.c,v retrieving revision 1.4
dsoundaudio.c +2 -0
@@ -32,7 +32,9 @@#define AUDIO_CAP "dsound"#include "audio_int.h" +#define WIN32_LEAN_AND_MEAN #include <windows.h> +#include <mmsystem.h> #include <objbase.h> #include <dsound.h>
Index: slirp/slirp.h
===================================================================
RCS file: /sources/qemu/qemu/slirp/slirp.h,v
retrieving revision 1.14
slirp.h +1 -0
@@ -29,6 +29,7 @@typedef uint64_t u_int64_t ;typedef char *caddr_t ; +#define WIN32_LEAN_AND_MEAN # include <windows.h> # include <winsock2.h> # include <sys/timeb.h>
Quoted 16 lines · Stefan Weil
Here is a patch using
WIN32_LEAN_AND_MEANwhich tries not to break dsound (andvl.c). I could only test it using cross compilation from Linux, so please send comments.Patch description:
* addWIN32_LEAN_AND_MEANto all inclusions ofwindows.h
* removewindows.hfromvl.c(it is already included otherwise)
* addmmsystem.htovl.canddsoundaudio.c(they need it and got it fromwindows.h)
* fixed indentation invl.c(wrong indentation was caused by an earlier patch from me)It will be difficult to avoid using variable names like "interface" in the future, so I still think using a minimal set of includes is the better (and faster) solution.
Quoted 30 lines
Anyway, Windows users need a working solution, so it would be nice if one of these patches could be applied to CVS HEAD.
Thank you.
StefanQuoted 22 lines · JonY
Quoted 6 lines · Stefan Weil
basetyps.his included bywindows.h/rpc.h. QEMU does not need it, so you can avoid it like this:#define
WIN32_LEAN_AND_MEAN
#include <windows.h>Quoted 6 lines
WIN32_LEAN_AND_MEANreduces the number of includes inwindows.hand increases compilation speed. And you don't have to rename variables like interface :-)Regards,
StefanHi,
I would prefer Eduardo's patch, defining
WIN32_LEAN_AND_MEANbreaks dsound.Thanks.
Ok, this patch works as intended. Thanks for the patch!
Slightly off topic, but still on Windows builds broken.
For some odd reason, dyngen-exec.h is always conflicting with stdint.h(?!!) for me. Can somebody explain why the typedefs are in dyngen-exec.h?
Mingw does not have ffs, localtime_r, gmtime_r, which breaks when compiling some files.
I propose adding the following for *_r functions on mingw hosts. #define localtime_r(x, y) memcpy(y, localtime(x), sizeof(y)) #define gmtime_r(x, y) memcpy(y, gmtime(x), sizeof(y))
There are many implementations of ffs(), but I'm unsure what it does :(
Quoted 12 lines · JonY
Ok, this patch works as intended. Thanks for the patch!
Slightly off topic, but still on Windows builds broken.
For some odd reason,
dyngen-exec.his always conflicting withstdint.h(?!!)for me. Can somebody explain why the typedefs are indyngen-exec.h?Mingw does not have ffs,
localtime_r,gmtime_r, which breaks when compiling some files.
Quoted 7 lines
I propose adding the following for *_r functions on mingw hosts. #define
localtime_r(x, y)memcpy(y, localtime(x), sizeof(y))#definegmtime_r(x, y)memcpy(y, gmtime(x), sizeof(y))There are many implementations of
ffs(), but I'm unsure what it does :(From the man page: ffs - find first bit set in a word
Typically, gcc provides a built-in function ffs, so there is no need to get an implementation for Windows. The missing prototype just gives a warning. I send here a patch which adds the prototype to osdep.h (only for Win32).
gmtime_r is really missing (see hw/omap.c). This was already discussed in another thread,
but not solved up to now.
Stefan
Index: osdep.h
===================================================================
RCS file: /sources/qemu/qemu/osdep.h,v
retrieving revision 1.11
osdep.h +1 -0
@@ -56,6 +56,7 @@int qemu_create_pidfile (const char *filename); #ifdef _WIN32 +int ffs(int i); typedef struct { long tv_sec; long tv_usec;
Quoted 1 line
Typically, gcc provides a built-in function ffs
Actually, not it doesn't.
As with many other standard functions, gcc will sometimes optimize it, maybe expanding to inline code. However there's always the possibility of falling back to the standard C library implementation.
Paul