msvc2010 cannot compile, proposing patch

Romain Pokrzywka romain.pokrzywka at kdab.com
Thu Mar 24 16:44:10 CET 2011


On Thursday 24 March 2011 09:04:08 Wolfgang Rohdewald wrote:
> 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-winso
>ck-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...
> ...

Gaah I can't believe they still haven't fixed that mess _in their own headers_ !

I guess you can commit your fix, please just make sure to test it with other compilers first (at least msvc2008 and 
mingw) to make sure it doesn't break them, or if that's the case please scope if with a #ifdef _MSC_VER >= XXX block 
(don't know what the version number is for msvc2010). Also a little comment explaining the reason, like you did in your 
mail, would be nice for future reference.

Thanks!


-- 
Romain Pokrzywka | romain.pokrzywka at kdab.com | Senior Qt Software Engineer & Trainer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2396 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-windows/attachments/20110324/4c44a808/attachment.p7s 


More information about the Kde-windows mailing list