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: Wrapper function for curl_easy_setopt()

From: Patrick Schlangen via curl-library <>
Date: Tue, 24 Oct 2023 10:55:49 +0000


> Am 24.10.2023 um 12:24 schrieb Vladimir Levijev via curl-library <>:
> So I tried it with #define but then you deal with static name of the error buffer and the GOTO label (in some parts we use it, but not everythere).

not exactly nice, but this might do the trick:

#define my_setopt(handle, option, ...) (last_option = #option, curl_easy_setopt(handle, option, __VA_ARGS__))

void foo() {
  const char *last_option = "none";

  // ...

  if (!my_setopt(e, CURLOPT_FOO, 123)) {
    printf("Error in %s!\n", last_option);



Received on 2023-10-24