플러그인을 개발 중입니다. 다음 코드를 살펴보십시오. std :: ofstream은 DLL에서 다르게 동작합니다.
string request(char post_params[]) {
CURL *curl;
CURLcode res;
std::string buffer; //here we'll write response
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_params);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(post_params));
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return buffer;
}
....
bool perform(..) {
std::ofstream file ("d:/t/t.txt");
file << "opened";
file.close();
string resp = request(....);
...
}
코드가 응용 프로그램 내부에서 시작되는 경우
이 파일d:/t/t.txt
이 생성되지만 코드가 DLL로 컴파일하면, 내 플러그인을 실행하는 응용 프로그램에서 실행되는 파일이 만들어지지 않습니다. 그러나 내가
string resp = request(....);
줄을 주석으로 뒤 따르고 있다면,
은이 될 것입니다. 누군가 여기서 나에 대해 설명해 줄 수 있니?
시도해 볼 수 있습니까 :: std :: ofstream file; file.open ("d : /t/t.txt"); ? 확실하지는 않지만 확인 만하십시오. 자세한 내용이 필요합니다. – Arunmu
아주 이상합니다. 함수의 나머지 부분에서이 행동을 일으키는 코드를 정확히 수립하고 결과를 게시 할 때까지'perform()'의 일부를 주석 처리하여 추가로 범위를 좁힐 수 있습니까? – NPE
'file.open (...)'도 똑같이 수행 – Eugeny89