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

[libvirt] [PATCH] winsock2.h must always be included before windows.h

From: "Daniel P. Berrange" <berrange redhat com>

Some GNULIB headers (eg unistd.h) will often need to include
winsock2.h for various symbols. There is a rule that winsock2.h
must be included before windows.h. This means that any file
which does

  #ifdef WIN32
  #include <windows.h>
  #include <unistd.h>

is potentially broken. A simple rule is that /all/ includes of
windows.h must be matched with a preceeding include of winsock2.h
regardless of whether unistd.h is used currently
 src/util/util.c           |    3 +++
 src/vbox/vbox_MSCOMGlue.c |    3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/util/util.c b/src/util/util.c
index 28a4fe7..a71b0d6 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -65,6 +65,9 @@
 #ifdef WIN32
+# ifdef HAVE_WINSOCK2_H
+#  include <winsock2.h>
+# endif
 # include <windows.h>
 # include <shlobj.h>
diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c
index b07d6a7..68810fb 100644
--- a/src/vbox/vbox_MSCOMGlue.c
+++ b/src/vbox/vbox_MSCOMGlue.c
@@ -22,6 +22,9 @@
 #include <config.h>
+# include <winsock2.h>
 #include <windows.h>
 #define nsCID CLSID

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