cURL / Mailing Lists / curl-library / Single Mail


Re: Using libcurl in c++

From: Daniel Stenberg <>
Date: Fri, 20 Feb 2009 10:27:33 +0100 (CET)

On Thu, 19 Feb 2009, Jan wrote:

> currently i'm having exactly the same problem as described here:

Right, libcurl is C not C++ so there's no 'this' pointer (implicitly) passed
to the callback.

> unfortunately, i still dont get how to solve this. i read this solution:
> but i dont get what has to be placed in the size_t WriteMemoryCallback(void
> *ptr, size_t size, size_t nmemb) function?

That's a callback you control so you write whatever you want in that function.
That's unrelated to what language you use.

The point of that particular solution for C++ is that the function is then
made "static" so thus there's no this pointer involved.

I believe you can also use the fourth argument pointer to fiddle in the this
pointer in case you really want to do it.

There's also the curlpp binding if you fancy using a more C++'ish approach.

Received on 2009-02-20