qualifications in prototypes
Doug Gwyn
gwyn at smoke.BRL.MIL
Tue Aug 7 22:20:31 AEST 1990
In article <1896 at tkou02.enet.dec.com> diamond at tkou02.enet.dec.com (diamond at tkovoa) writes:
>In article <476 at mtndew.UUCP> friedl at mtndew.UUCP (Stephen J. Friedl) writes:
>SF> extern int stat(char *filename, struct stat *stptr);
>SF>Shouldn't the "filename" argument be const qualified?
More accurately, *filename should be const-qualified.
The relevant constraints are given in 3.3.16.1, in particular:
both operands are pointers to qualified or unqualified versions
of compatible types, and the type pointed to by the left [in
this context, the declared function parameter] has all the
qualifiers of the type pointed to by the right [the actual
function argument].
Certainly, const char * has all the qualifiers of char *, as well as
one additional qualifier.
For practical examples, see many of the standard library functions in
section 4 of the standard.
More information about the Comp.lang.c
mailing list