Article View: comp.std.c
Article #6214const and struct pointers
From: Robert Adsett
Date: Fri, 23 Feb 1990 23:24
Date: Fri, 23 Feb 1990 23:24
33 lines
1510 bytes
1510 bytes
I ran into a problem with my compiler (it claims to be ANSI
compliant) the other day while using the const keyword. I'd like to
know if whether I've run into a compiler bug or my understanding of
the const keyword is incomplete. The problem shows up in the code
fragment that follows.
#include <math.h>
struct qwert { int a; double b;};
void asdf( struct qwert a);
const double a = 3.0;
void junk( const double *b, const struct qwert *c)
{
(void)exp(a); /* Works */
(void)exp(*b); /* Works */
asdf( *c); /* Type mismatch ???? */
}
The compiler gives a type mismatch in argument error for the line
indicated. If I either add const to the prototype or remove it from
the argument to junk it compiles without error. Is there some reason
that 'const double *b' should be treated differently from 'const
struct qwert *c'? Surely it's not possible for a structure that's
passed by value to be changed by the called function?
--
Robert Adsett <semicon@watsci.UWaterloo.ca>
Dept. of Phys, Univ. of Waterloo, Waterloo Ont. Canada
Technical Details
Message-ID:
<1214@watserv1.waterloo.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watsci!semiconShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watsci!semicon From: semicon@watsci.uwaterloo.ca (Robert Adsett) Newsgroups: comp.std.c,comp.lang.c Subject: const and struct pointers Message-ID: <1214@watserv1.waterloo.edu> Date: 23 Feb 90 23:24:14 GMT Sender: daemon@watserv1.waterloo.edu Reply-To: semicon@watsci.UUCP (Robert Adsett) Distribution: all Organization: University of Waterloo, Waterloo Ontario, Canada Lines: 33