cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Mistake in user guide documentation regarding C++(lib-curl-the-guide)

From: Gisle Vanem <giva_at_bgnett.no>
Date: Mon, 12 Jul 2004 11:47:55 +0200

"Nye, Jason" <jnye_at_osii.com> said:
 
> The statement saying "The callbacks must be Plain C" should be replaced
> with "The callbacks CANNOT be non-static class member functions". The
> discussion about extern "C" is all wrong. All extern "C" does is prevent
> name mangling and has nothing to do with the this pointer or how
> function pointers at runtime are interpreted.
 
What was meant was probably that the callback must be 'cdecl'.
Since libcurl probably cannot be compiled with MSVC and 'fastcall'
globally, all user-callbacks must also be 'cdecl'

But the callbacks should IMHO be decorated correctly.
In <curl/curl.h> do something like:

#ifndef __cdecl
#define __cdecl
#endif

typedef size_t (__cdecl *curl_write_callback)(char *buffer,
                                      size_t size,
                                      size_t nitems,
                                      void *outstream);
Received on 2004-07-12