🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #754

the "const" qualifier

#754
From: Andy Fyfe
Date: Sun, 15 Oct 1989 04:52
24 lines
1463 bytes
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@csvax.caltech.edu
            wjafyfe@caltech.bitnet
            andy@cit-vax.UUCP	(...!ames!elroy!cit-vax!andy)
Technical Details
Message-ID: <12239@cit-vax.Caltech.Edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!cit-vax!andy

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!cit-vax!andy
From: andy@cit-vax.Caltech.Edu (Andy Fyfe)
Newsgroups: comp.std.c
Subject: the "const" qualifier
Message-ID: <12239@cit-vax.Caltech.Edu>
Date: 15 Oct 89 04:52:07 GMT
Reply-To: andy@csvax.caltech.edu (Andy Fyfe)
Organization: California Institute of Technology
Lines: 24