msvc2010 cannot compile, proposing patch

Wolfgang Rohdewald wolfgang at rohdewald.de
Thu Mar 24 15:04:08 CET 2011


lots of error messages, see below

googling tells me that the order of include files is wrong somewhere,
concerning windows.h and winsock2.h

like:
http://cboard.cprogramming.com/windows-programming/133334-conflicting-winsock-h-winsock2-h.html
http://www.ogre3d.org/forums/viewtopic.php?f=16&t=50028

the 2nd link has a good explanation:
Or you can ignore the include order and just put #define _WINSOCKAPI_ as the first line in the cpp.
The winsock2.h file defines both _WINSOCKAPI_ (to stop the old one loading)
and _WINSOCK2API_ (to avoid including itself several times)

so unless I want to mess around wherever with order of includes, I can get this
compiling with this patch which I want to commit if nobody objects:

--- /home/wr/src/kdewin/include/msvc/windows.h  2011-03-24 14:07:18.502759902 +0100
+++ windows.h   2011-03-24 15:00:33.124950000 +0100
@@ -21,6 +21,8 @@
 #ifndef KDEWIN_WINDOWS_H
 #define KDEWIN_WINDOWS_H
 
+#define _WINSOCKAPI_
+
 /* avoid min/max conflicts (see http://support.microsoft.com/kb/143208) */
 #ifndef NOMINMAX
 # define NOMINMAX


sipkdeuipart0.cpp^M
q:/pykde/sip/kdeui/kdeuimod.sip(23) : warning C4068: unknown pragma^M
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition^M
        C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(460) : see previous definition of 'AF_IPX'^M
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\ws2def.h(124) : warning C4005: 'AF_MAX' : macro redefinition^M
        C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(479) : see previous definition of 'AF_MAX'^M
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\ws2def.h(168) : warning C4005: 'SO_DONTLINGER' : macro redefinition^M
        C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(402) : see previous definition of 'SO_DONTLINGER'^M
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\ws2def.h(212) : error C2011: 'sockaddr' : 'struct' type redefinition^M
....
and so on...
...

-- 
Wolfgang


More information about the Kde-windows mailing list