[Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification
Jeremy Hylton
jeremy at alum.mit.edu
Fri Feb 10 18:06:21 CET 2006
More information about the Python-Dev mailing list
Fri Feb 10 18:06:21 CET 2006
- Previous message: [Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification
- Next message: [Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
It looks like a solution may be to define it as "const char * const *" rather than "const char **". I'll see if that works. Jeremy On 2/10/06, "Martin v. Löwis" <martin at v.loewis.de> wrote: > Jeremy Hylton wrote: > > I admit that I'm also puzzled by Jack's specific question. I don't > > understand why an array passed to PyArg_ParseTupleAndKeywords() would > > need to be declared as const. I observed the problem in my initial > > changes but didn't think very hard about the cause of the problem. > > Perhaps someone with better C/C++ standards chops can explain. > > Please take a look at this code: > > void foo(const char** x, const char*s) > { > x[0] = s; > } > > void bar() > { > char *kwds[] = {0}; > const char *s = "Text"; > foo(kwds, s); > kwds[0][0] = 't'; > } > > If it was correct, you would be able to modify the const char > array in the string literal, without any compiler errors. The > assignment > > x[0] = s; > > is kosher, because you are putting a const char* into a > const char* array, and the assigment > > kwds[0][0] = 't'; > > is ok, because you are modifying a char array. So the place > where it has to fail is the passing of the pointer-pointer. > > Regards, > Martin >
- Previous message: [Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification
- Next message: [Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list