the "const" qualifier
Andy Fyfe
andy at cit-vax.Caltech.Edu
Sun Oct 15 14:52:07 AEST 1989
The GNU C compiler permits assignment (where assignment includes
things such as parameter passing) of a "char *" to a "const char *",
but not of a "char **" to a "const char **" without an explicit
cast. Rms assures me that this is in strict accordance with the
ANSI standard.
This came up when I provided the following prototype for
execv:
extern int execv(const char *path, const char **args);
Gcc gave a warning about incompatible pointer types when execv was
called with a "char **" as the second parameter.
While "execv" may be a bad example (as it's not expected to
return at all), 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").
I was wondering if someone could clarify this for me.
Andy Fyfe
andy at csvax.caltech.edu
wjafyfe at caltech.bitnet
andy at cit-vax.UUCP (...!ames!elroy!cit-vax!andy)
More information about the Comp.std.c
mailing list