   Need to pass additional paremeter in function pointer
  Ive got a C library (python c-api) which expects some function pointers to be passed to it. These function pointers need to take the form of: int MyFunc(PyObject *in, void *out)The thing is I really need to pass an additional string argument to these functions (the strings are constant and knwon at compile times).Is there some way todo this, I know with boost::function object I can use boost::bind to define the third arguments, but is it possible when createing a basic c compatible function pointer?Another solution I tried was making the functions I'm passing to python template functions with a string template argument, however apparently this is not allowed and wont compile...template<wchar_t *arg> int MyFunc(PyObject *obj, void *out){...}int (__cdecl *myFuncPtr)(PyObject *,void *) = Arg_MakeString<L"MyString">;//fails//1>c:\... : error C2440: 'initializing' : cannot convert from 'int (__cdecl *)(PyObject *,void *)' to 'int (__cdecl *)(PyObject *,void *)'//1>   None of the functions with this name in scope match the target typeA third option that came to mind was could I dynamically generate another function that can handle the last argument, eg so I could do the following:int MyFunc(PyObject *obj, void *out, const wstring &str){...}... int (*myFuncPtr)(PyObject*,void*) = CreateMyFuncPtr(MyFunc, L"MyString");
Quote:Original post by Fire Lancerint MyFunc(PyObject *in, void *out)The thing is I really need to pass an additional string argumentWhat is "out"? Seems to be some generic, vague stuff. Can't you make a struct containing your string and the "real out", and then have out point to that?   ;  Thats actauly a good idea, since python just passes that pointer straight through and expects the user to allocate memory and know what it is, I guess I could use it an an input rather than just the output like the python api expects :)Should have thaught of that lol...   ;  Could you show a little bit more of the context for what you're doing? Where does the function pointer get passed to? What is the string that you want to pass to the pointed-to function, and why are you passing it? Where does the PyObject come from (i.e. what will the Python code look like)?   