Xref: utzoo comp.lang.c:31709 comp.std.c:3563 Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!andrew From: andrew@alice.UUCP (Andrew Hume) Newsgroups: comp.lang.c,comp.std.c Subject: Re: ansi weirdness Summary: correction Message-ID: <11312@alice.UUCP> Date: 9 Sep 90 15:41:23 GMT References: <11305@alice.UUCP> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 28 In article <11305@alice.UUCP>, andrew@alice.UUCP (Andrew Hume) writes: ~ ~ 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; ~ ~ 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? let me correct an error and clarify; the fragment contains a bug - it should be typedef int (*fn)(struct x *); extern int fn1(struct x *); extern fn fp = fn1; i understand technically (i think) what is going on. the first line introduces a type struct x which goes away at the end of the prototype and can never be used again. my question is why didn't ANSI do what C++ does here and export the type up to file scope? andrew@research.att.com