curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: CURLOPT_WRITEFUNCTION issues - warning: curl_easy_setopt expects a curl_write_callback argument

From: Gavin Henry via curl-library <>
Date: Fri, 21 Jan 2022 11:13:53 +0000

> It enables link-time optimizations. The compiler/linker can see further into to the source, and detect errors not seen at the module level.
> It's saying that your callback routine must be declared/typedefed as a "curl_write_callback".

Thanks Tim.

Which is actually:

typedef size_t (*curl_write_callback)(char *buffer,
                                      size_t size,
                                      size_t nitems,
                                      void *outstream);

as per curl.h and is the same as the example code:

so if I switch to:

static curl_write_callback curl_to_jansson_to_version(void *buffer, size_t size,
                                    size_t nmemb, json_t *json)

I get:

Incompatible integer to pointer conversion returning 'unsigned long'
from a function with result type 'curl_write_callback' (aka 'unsigned
long (*)(char *, unsigned long, unsigned long, void *)')

error: returning ‘size_t’ {aka ‘long unsigned int’} from a function
with return type ‘curl_write_callback’ {aka ‘long unsigned int
(*)(char *, long unsigned int, long unsigned int, void *)’} makes
pointer from integer without a cast [-Werror=int-conversion]
   43 | return size * nmemb;
      | ~~~~~^~~~~~~

so I'd need to cast that.

Gavin Henry.
Received on 2022-01-21