cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

7.18.2: Compilation with MS Visual Studio 2005 causes error C2894 / extern "C" problem

From: Stefan Krause <stefan.krause_at_gmx.net>
Date: Wed, 01 Oct 2008 20:20:46 +0200

Hi libCurl users,

I have got a C++ file which includes the curl.h header and which cannot
be compiled. The following error is generated

C:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\Include\wspiapi.h(44) : error C2894: templates cannot be declared to
have 'C' linkage

The file's content is:

...

extern "C"
{
   #include "curl/curl.h"
}

In curl.h line 59 ws2tcpip.h is included. That file itself includes
wspiapi.h.

I assume that the error occurs because I placed #include "curl/curl.h"
in an extern "C" section and I compiled a C++ file. In that case,
the preprocessor flag __cplusplus is set by the compiler and in
wspiapi.h at line 44 the template is instantiated.

Now, the solution seems fairly simple. I just remove the extern "C"
section. In curl.h, multi.h, easy.h etc extern "C" sections are already
defined. So, there should be no need to do it again line above.

In C++ files it should be enough to just include curl.h, the extern "C"
linkage specification is done by libCurl itself.
Further more, extern "C" must not be used (at least when compiling with
VS 2005.

Am I right or wrong ? In case I am wrong, please point out a alterntive
solution (if available, of course :-)

Best regards,

     Stefan
Received on 2008-10-01

These mail archives are generated by hypermail.

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

File upload with ASP.NET