Xref: utzoo comp.std.c:2499 comp.lang.c:26248 Path: 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 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 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 Dept. of Phys, Univ. of Waterloo, Waterloo Ont. Canada