1

I just define a function as below and export it to python by using boost.python.

I have a doubt what is the corresponding type of [File* local_conf] in python.

size_t curl_conf(const char* conf_url,FILE *local_conf)
 {
     return 0;
 }


  BOOST_PYTHON_MODULE(curl_conf)
 {
     using namespace boost::python;
       def("curl_conf",curl_conf,"get conf");
 }

1 Answer 1

1

As quick google search and I found this blog article that seems to exactly answer your question : http://bfroehle.com/2011/10/file-and-boost-python/

You have to write a small wrapper as there is no direct conversion.

An example of the wrapper can be found here : https://gist.github.com/1265889

However, an alternative is to pass a string and open the file on the c++-side. It's up to you.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, It needs some work to transfer from fd to FILE ,vice versa . filepath --fopen()-->FILE*; filepath--open()--fd; fd--fdopen()-->FILE*; fd--readlink(/proc/%getpid()/fd/%fd"))-->filepath;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.