Jason Nye pointed out that callbacks don't need to use the "C namespace"
This commit is contained in:
parent
0c54013ee3
commit
a92b7c1b16
@ -571,24 +571,20 @@ CURLOPT_PROGRESSDATA. libcurl won't touch it.
|
|||||||
There's basically only one thing to keep in mind when using C++ instead of C
|
There's basically only one thing to keep in mind when using C++ instead of C
|
||||||
when interfacing libcurl:
|
when interfacing libcurl:
|
||||||
|
|
||||||
"The Callbacks Must Be Plain C"
|
The callbacks CANNOT be non-static class member functions
|
||||||
|
|
||||||
So if you want a write callback set in libcurl, you should put it within
|
Example C++ code:
|
||||||
\&'extern'. Similar to this:
|
|
||||||
|
|
||||||
.nf
|
.nf
|
||||||
extern "C" {
|
class AClass {
|
||||||
size_t write_data(void *ptr, size_t size, size_t nmemb,
|
static size_t write_data(void *ptr, size_t size, size_t nmemb,
|
||||||
void *ourpointer)
|
void *ourpointer)
|
||||||
{
|
{
|
||||||
/* do what you want with the data */
|
/* do what you want with the data */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
This will of course effectively turn the callback code into C. There won't be
|
|
||||||
any "this" pointer available etc.
|
|
||||||
|
|
||||||
.SH "Proxies"
|
.SH "Proxies"
|
||||||
|
|
||||||
What "proxy" means according to Merriam-Webster: "a person authorized to act
|
What "proxy" means according to Merriam-Webster: "a person authorized to act
|
||||||
|
Loading…
x
Reference in New Issue
Block a user