this answer을 읽은 후 해결책이 있다고 생각했습니다. 적어도 거기에 대한 대답은 내가하고 싶은 것이지만 구현에 문제가 있습니다. 여기 boost :: function :: target을 사용하여 함수 포인터를 가져올 때 null 포인터
내가typedef map<string, double*> myMap;
typedef int (*ftwpt)(const char*, const struct stat*, int);
typedef boost::function<int(const char*, const struct stat*, int)> MyFTWFunction;
int myFunction(const char*, const struct stat*, int, myMap*);
int main()
{
myMap m_map;
char tmpdir[] = "/tmp/mytmp";
MyFTWFunction f = boost::bind(myFunction,_1,_2,_3, &m_map);
ftwpt* fpt = f.target<ftwpt>();
if (fpt)
status = ftw(tmpdir, *fpt, 50);
else
{
cout << "Boost could not perform runtime conversion on function pointer" << endl;
return (EXIT_FAILURE);
}
}
프로그램이 오류 또는 경고와 함께 컴파일을하려고하고있는 무슨의 개요입니다하지만 난 (FPT) 널 포인터를 얻고 것은) (f.target에서 반환; 런타임에. 부스트가 런타임 변환을 수행 할 수없는 경우 위의 stackoverflow 질문에 링크 된 참조에서 null 포인터가 반환되는 것 같습니다. Boost가 런타임 변환을 수행하지 못할 수도 있습니다. 어떤 아이디어?
@Konrad 코드가 실패하는 이유도 설명 : http://stackoverflow.com/questions/282372/demote-boostfunction-to-a-plain-function-pointer/512233 # 512233 –
@HazyBlueDot -이 질문은 C가 아니라 C가 아니라 C입니다. 올바르게 태그를 지정하십시오. –