Thanks guys. Appreciate it!
I don't expect a response about this, because it's a rather strange question:
Since it relates to the OP code, I'd like to ask if there is a way to convert a class method to act like a C function? (handle/remove "this" parameter before being invoked). I've attempted boost::bind.
I ask because I'd rather pass cURL a class method instead of a function.
If it's not possible.. that's fine. I only ask because the error intrigues me:
Request(std::string const& url)
//later in constructor
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, boost::bind(&Request::OnReadContent, this, _1, _2, _3, _4));
size_t OnReadContent(void *buffer, size_t size, size_t nmemb, void *userp)
std::cout << "OnReadContent" << std::endl;
So then it's complaining that it's defined as __thiscall, when cURL calls it as __stdcall or __cdecl? (ie. the typedef below). From the library source, the error line:
Run-Time Check Failure #0 - The value of ESP was not properly saved across the function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Calling a method of object set which is operator() of boost::bind which calls a method of class Request? I can see how that could cause problems. The typedef for the function it's calling is:
size_t wrote = data->set.fwrite_func(ptr, 1, len, data->set.out);
So perhaps some sort of cast from boost::bind or Request::OnReadContent(this, x, x, x, x) to curl_write_callback? or some sort of preprocessor?
typedef size_t (*curl_write_callback)(char *buffer,
Of course I could make it static... and pass -this- as the 4th parameter, but like I said.. I was curious.