the "const" qualifier
Maarten Litmaath
maart at cs.vu.nl
Tue Oct 17 02:28:14 AEST 1989
gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
\... Note that the
\first-level ignoring of qualifiers on the pointed-to types allows a
\(char *) argument to be passed without casting to a function declared as
\taking a (const char *) parameter, but the qualifier-ignoring does not
\occur at second or lower levels.
^^^^^^^^^^^^^^^^^^^^^^
Why? (See below.)
\> extern int execv(const char *path, const char **args);
\>... my understanding of such a prototype is that the
\>function will not change the characters pointed to by "path", or
\>by "args[0], args[1], ...". Passing pointers that permit such
\>changes I would expect to be allowed (and is, for "path").
\
\You understand the meaning okay. The problem ultimately stems from a
\slight overloading of semantics for "const". [...]
Could you elaborate on this counter-intuitivity?
--
The UNIX Way of doing something [...] is to make it look as much like a filter
as possible. (Richard O'Keefe) | Maarten Litmaath (mcsun!botter!maart)
More information about the Comp.std.c
mailing list