Path: utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!swrinde!mips!troi!tardis!peter From: peter@dbaccess.com (Peter A. Castro) Newsgroups: comp.lang.c Subject: Re: ansi weirdness Message-ID: <119@tardis.dbaccess.com> Date: 10 Sep 90 20:08:02 GMT References: <11305@alice.UUCP> Organization: DB/Access Inc., Santa Clara, CA Lines: 32 in article <11305@alice.UUCP>, andrew@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@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 \// // ||