const and struct pointers
James Seidman
jseidman at jarthur.Claremont.EDU
Mon Feb 26 06:34:00 AEST 1990
In article <414 at charyb.COM> will at charyb.UUCP (Will Crowder) writes:
>Actually, I'm somewhat surprised that Turbo C didn't just throw out the
>"const" in:
>
> void asdf(const struct qwert a);
>
>I wouldn't think "const" would mean much for a non-pointer parameter passed
>by value.
I would think that "const" in this context would mean pretty much the same
thing as it would in a normal variable declaration. That is, that the
function asdf() won't change the parameter a locally. Granted, about the
only use for this is to generate warnings if you accidentally do assign a
new value to a (like in "if (a = 2) then...") and to improve readibility of
code. Of course, this doesn't explain why the compiler complained, but it
should not just throw away the "const" qualifier.
--
-------------------------------------------------------------------------------
Jim Seidman, Harvey Mudd College, Claremont, CA 91711. (714) 621-8000 x2026
DISCLAIMER: I don't even know if these are opinions, let alone those of
anyone other than me.
More information about the Comp.lang.c
mailing list