I am rewriting the C wrapper around the C Python API (Python 1.5), and I noticed that the Py_VaBuildValue function uses a variable number of arguments. I was wondering if I should use the same in my C ++ function shell to go to that function, or if there is more C ++ way to handle this?
I know that variable functions can be the cause of an unspeakable problem, so I would prefer to avoid using if there is a better way.
EDIT:
So here is the C code that I need to do in the C ++ function:
int Set_Global(char *modname, char *varname, char *valfmt, ... ) {
int result;
PyObject *module, *val;
va_list cvals;
va_start(cvals, valfmt);
module = Load_Module(modname);
if (module == NULL)
return -1;
val = Py_VaBuildValue(valfmt, cvals);
va_end(cvals);
if (val == NULL)
return -1;
result = PyObject_SetAttrString(module, varname, val);
Py_DECREF(val);
return result;
}
So, I am doing the same function with std :: string instead of char *, and I want to change the ellipsis to something more than C ++, so that I can, however, go to Py_VaBuildValue inside the function.
source
share