char* arguments in C API
linux at jrockey.com
Sun Mar 23 17:41:11 CET 2003
I looked around for a list dedicated to the Python/C API, and couldn't find
one, so I hope this is an appropriate place to ask this question.
The Python API declares most of its functions that take a C string using
char* (as opposed to const char*). This results in a warning in stricter
compilers if you do something like
PyObject *spam_module = PyImport_ImportModule("spam");
To stop the warning I have to cast to char*:
PyObject *spam_module = PyImport_ImportModule((char*)"spam");
Is there an alternative to this slightly ugly hack? Shouldn't parameters
like these be const char*? Or is it just an historical thing?
More information about the Python-list