Haxx ad

curl's project page on


cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1824894 ] Recent addition of ws2tcpip.h to curl.h breaks C++ apps

From: <>
Date: Wed, 07 Nov 2007 08:07:36 -0800

Bugs item #1824894, was opened at 2007-11-02 17:18
Message generated for change (Comment added) made by scantor
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: compile or build problem
Group: portability problem
Status: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Scott Cantor (scantor)
Assigned to: Daniel Stenberg (bagder)
Summary: Recent addition of ws2tcpip.h to curl.h breaks C++ apps

Initial Comment:
Bit of a mess I think, this must have to do with the whole socklen_t mess I've run into with the older Windows compiler, but this recent addition of ws2tcpip.h to fix that issue is causing a C++ build problem with the new 7.17.1 release.

That header pulls in the Microsoft header <wspiapi.h> at the bottom of the file. That in turn includes an actual C++ template (do NOT ask me why) and because curl.h is wrapping itself in extern "C", that breaks the build with this error:

c:\program files\microsoft visual studio 8\vc\platformsdk\include\wspiapi.h(44) : error C2894: templates cannot be declared to have 'C' linkage

I think the fix for this is to stop wrapping the #includes in curl.h inside the extern "C" block. When you pull in headers, you really should refrain from assuming it's C linkage in case somebody does something like this.

You'll need to carefully wrap your own declarations in the extern "C" block, but pull in headers outside them. This will take quite a bit of testing, I suspect.

Another possibility MIGHT be to refrain from including that ws2tcpip.h header on anything other than the old VS6 compiler, but that may be more trouble, I didn't follow the socklen issue closely.


>Comment By: Scott Cantor (scantor)
Date: 2007-11-07 11:07

Logged In: YES
Originator: YES

Appears to work, thanks.


Comment By: Daniel Stenberg (bagder)
Date: 2007-11-06 16:26

Logged In: YES
Originator: NO

Yang Tse committed a fix to this problem today, it'd be great if you could
get tomorrow's daily snapshot or the current CVS and verify that it builds

Thanks for the report, case is closed.


Comment By: Scott Cantor (scantor)
Date: 2007-11-02 17:26

Logged In: YES
Originator: YES

As a quick fix, this change to curl.h in that spot might be an option:

#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
/* The check above prevents the winsock2 inclusion if winsock.h already
   included, since they can't co-exist without problems */
  #ifdef __cplusplus
#include <winsock2.h>
#include <ws2tcpip.h>
  #ifdef __cplusplus
    extern "C" {

A bit ugly, but it would save us testing the impact of a larger fix for


You can respond by visiting:
Received on 2007-11-07

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET