[C++-sig] working around the non-const Python C API (original) (raw)
Jeremy Hylton jeremy at alum.mit.edu
Wed Dec 14 16:57:13 CET 2005
- Previous message: [C++-sig] working around the non-const Python C API
- Next message: [C++-sig] Pyste and pointers on const data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I thought I'd let folks in C++ land know that I did make some improvements on the Python trunk. I updated all of the functions that commonly take string literals in extension modules -- PyMethodDef, the string tp slots of a type object, PyArg_ParseTuple and friends, Py_BuildValue, and PyObject_GetAttrString() and friends.
Jeremy
On 12/2/05, Jeremy Hylton <jeremy at alum.mit.edu> wrote:
I was curious if anyone had advice on how to work around the fact that much of the Python C API asks for char* when it really intends to treat it as a const char*. An example of this behavior is the PyMethodDef struct, which has char* mlname and char* mldoc parameters. If you use a string literal, you get a warning about casting a const char* to a char*. I can add a cast around each literal, but that's really ugly.
Is there a good way to avoid the warnings? Secondarily, I know that python-dev is a bit hesitant about const correctness, but we did get some const char* types added with the new bytecode compiler. Perhaps it's worthwhile to try changing a few of the most egregious cases to use const char*. Jeremy
- Previous message: [C++-sig] working around the non-const Python C API
- Next message: [C++-sig] Pyste and pointers on const data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]