ansi weirdness
Peter A. Castro
peter at dbaccess.com
Tue Sep 11 06:08:02 AEST 1990
in article <11305 at alice.UUCP>, andrew at alice.UUCP (Andrew Hume) says:
>
>
> the following C fragment fails with a strict ANSI compiler (lcc)
> but compiles with sloppy ones (e.g. gcc):
>
> typedef int (*fn)(struct x *);
> extern int fn1(struct x *);
> extern fn *fp = fn1;
^^^
don't you mean "extern fn fp = fn1;" ?
>
> the ostensible reason is that the two struct x's are different
> (or at least, have different scopes).
> this may be technically correct but is just wrong.
> can anyone explain why anyone would want this batshit behaviour?
I tried running your example through two ANSI compilers (RS/6000 XLC,
and Amiga Aztec C 5.0) and on the second extern got a message:
"Illegal initialization between types POINTER and POINTER."
However, to me your extern looks like you are making fp a pointer to
a pointer to a function. In that case, the compiler is correct in that
a pointer to a function is not the same as a pointer to a pointer to
a function. However, a compiler that is less stringent will let it
pass because it resolves that pointers are the same base type.
I guess I have to ask what was your intent.
--
Peter A. Castro INTERNET: peter at dbaccess.com // //|
c/o DB/Access Inc. UUCP: {uunet,mips}!troi!peter // //||
2900 Gordon Avenue, Suite 101 FAX: (408) 735-0328 \\ // //-||-
Santa Clara, CA 95051 TEL: (408) 735-7545 \// // ||
More information about the Comp.lang.c
mailing list