0
当我包裹在课堂上我面对问题的libcurl:在构造函数中使用curl_easy_init导致段错误
Foo::Foo()
{
curl = curl_easy_init();
if (!curl)
throw std::runtime("Can't initialize libcurl");
}
char* Foo::GetPage(char *url)
{
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)data);
CURLcode res = curl_easy_perform(curl);
}
我上GETPAGE功能的第一线段错误(设置URL)。如果我在GetPage中使用curl,一切都可以。任何人都面临类似的问题?
谢谢,我找到了问题。可变卷曲 - 是Foo类的成员,所以当我使用它时会导致段错误。变量的值是正确的,但不能放到库中。 – serkos 2014-09-30 07:21:20