curl-library
Re: Newbie Question: libcurl with C++
Date: Fri, 12 Oct 2001 13:49:32 +0200 (MET DST)
On Fri, 12 Oct 2001, Andre Moll wrote:
> I am trying to use libcurl with C++ and can't bring it to work.
>
> This is my try, which leads into an Segmentation fault while using Method
> C.
>
> Any hints? Maybe somebody can send me a simple C++ Example. All Examples
> I found till now were C examples.
Yes, we've never received any C++ examples to show. The moment we get one,
we'll make it available...
> The Segfault happens while executing _ curl_easy_perform(curl_handle); _
> and only, if there is an internet connection established.
>
> I believe I make a general Mistake with passing WriteMemoryCallback the
> way I do it.
Yes you do that wrong.
The callback function must be a plain C function, not a C++ one. C++
functions all get an object pointer passed to them as an invisible (first)
argument, but C functions don't. So when libcurl calls the specified
function, there is no invisible argument, but your code falsely expects one.
Put your callback function within the extern "C" block, and things have a
much better chance to work!
-- Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/Received on 2001-10-12