Skip to contentSkip to conversation

w32: include winsock2.h before windows.h

PATCH Applied Paolo Bonzini 5 participants 8 messages Feb 9, 2016 – Feb 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w32: include winsock2.h before windows.h

Recent Fedora complains while compiling ui/sdl.c:

    /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

And with this patch we dutifully obey.

---
 include/sysemu/os-win32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/os-win32.h +1 -1
index 400e098..fbed346 100644
@@ -26,8 +26,8 @@
 #ifndef QEMU_OS_WIN32_H
 #define QEMU_OS_WIN32_H
 
-#include <windows.h>
 #include <winsock2.h>
+#include <windows.h>
 
 /* Workaround for older versions of MinGW. */
 #ifndef ECONNREFUSED
Signature · 1 line
2.5.0
#1 lore raw
Quoted 16 lines · Paolo Bonzini

Recent Fedora complains while compiling ui/sdl.c:

    /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

And with this patch we dutifully obey.

---
 include/sysemu/os-win32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/os-win32.h +0 -0
index 400e098..fbed346 100644

include/sysemu/os-win32.h line 33

Quoted 9 lines
include/sysemu/os-win32.h +1 -1
@@ -26,8 +26,8 @@
 #ifndef QEMU_OS_WIN32_H
 #define QEMU_OS_WIN32_H
 
-#include <windows.h>
 #include <winsock2.h>
+#include <windows.h>
 
 /* Workaround for older versions of MinGW. */
 #ifndef ECONNREFUSED

include/qemu/sockets.h also has windows.h included before winsock2.h

Presumably it didn't cause a failure for you because everything using sockets.h already pulls in osdep.h. A reason to prune sockets.h headers perhaps.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
Quoted 6 lines · Daniel P. Berrange

On Tue, Feb 09, 2016 at 03:16:57PM +0100, Paolo Bonzini wrote:
include/qemu/sockets.h also has windows.h included before winsock2.h

Presumably it didn't cause a failure for you because everything using sockets.h already pulls in osdep.h. A reason to prune sockets.h headers perhaps.

More generally we could prune anything including windows.h manually (there are a dozen or so .c and .h files doing that currently).

thanks
-- PMM

#3 lore raw
Quoted 9 lines · Peter Maydell
Quoted 6 lines · Daniel P. Berrange
Quoted 6 lines · Paolo Bonzini

include/qemu/sockets.h also has windows.h included before winsock2.h

Presumably it didn't cause a failure for you because everything using sockets.h already pulls in osdep.h. A reason to prune sockets.h headers perhaps.

More generally we could prune anything including windows.h manually (there are a dozen or so .c and .h files doing that currently).

I honestly do not have time to work on this. :(

Paolo

#4 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Daniel P. Berrange
Quoted 3 lines · Paolo Bonzini

include/qemu/sockets.h also has windows.h included before winsock2.h

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Presumably it didn't cause a failure for you because everything using sockets.h already pulls in osdep.h. A reason to prune sockets.h headers perhaps.

More generally we could prune anything including windows.h manually (there are a dozen or so .c and .h files doing that currently).

I honestly do not have time to work on this. :(

That's OK, I currently have a bunch of include file cleanups going through so one more won't hurt too much :-)

-- PMM

Reviewed-by on v1 1/1
#5 lore raw
In reply to Paolo Bonzini

Am 09.02.2016 um 15:16 schrieb Paolo Bonzini:

Quoted 16 lines

Recent Fedora complains while compiling ui/sdl.c:

    /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

And with this patch we dutifully obey.

---
 include/sysemu/os-win32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/os-win32.h +0 -0
index 400e098..fbed346 100644

include/sysemu/os-win32.h line 33

Quoted 9 lines
include/sysemu/os-win32.h +1 -1
@@ -26,8 +26,8 @@
 #ifndef QEMU_OS_WIN32_H
 #define QEMU_OS_WIN32_H
 
-#include <windows.h>
 #include <winsock2.h>
+#include <windows.h>
 
 /* Workaround for older versions of MinGW. */
 #ifndef ECONNREFUSED

Without that patch, windows.h will include winsock.h (which conflicts with winsock2.h) when compiling sdl.c.

Normally we define WIN32_LEAN_AND_MEAN, and windows.h won't include winsock.h.

include/ui/sdl2.h and ui/sdl.c undefine that macro, so the order of the include files is important.

Without testing this, I think that Paolo's patch is needed since commit e16f4c8770b73f530dad842a31298963b6c7e41d.

#6 lore raw
Quoted 5 lines · Stefan Weil

Without that patch, windows.h will include winsock.h (which conflicts with winsock2.h) when compiling sdl.c.

Quoted 9 lines

Normally we define WIN32_LEAN_AND_MEAN, and windows.h won't include winsock.h.

include/ui/sdl2.h and ui/sdl.c undefine that macro, so the order of the include files is important.

Without testing this, I think that Paolo's patch is needed since commit e16f4c8770b73f530dad842a31298963b6c7e41d.

That also explains why only that file complains. Thanks!

Paolo

#7 lore raw
In reply to Paolo Bonzini
Quoted 5 lines · Paolo Bonzini

Recent Fedora complains while compiling ui/sdl.c:

    /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

And with this patch we dutifully obey.

Applied to -trivial, adding Stefan's comments to the commit message too.

Thanks,

/mjt