Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!tektronix!hplabs!sri-unix!gwyn@BRL-VLD.ARPA From: gwyn@BRL-VLD.ARPA Newsgroups: net.lang.c Subject: Re: forward declared structures Message-ID: <447@sri-arpa.UUCP> Date: Thu, 26-Jul-84 12:13:44 EDT Article-I.D.: sri-arpa.447 Posted: Thu Jul 26 12:13:44 1984 Date-Received: Sat, 28-Jul-84 10:27:58 EDT Lines: 27 From: Doug Gwyn (VLD/VMB) Technically it is an error to declare struct s *ps; without having defined what a "struct s" is first. Because of the forward-reference problem, most C compilers allow declaring a pointer to a struct before the struct is defined, so that struct a { struct b *bp; }; struct b { struct a *ap; }; is supported. They get away with this only because all pointers-to-struct happen to have the same run-time form. The declaration of `struct s' inside a function is local to that function, which is why it is unknown later when you attempt to use the pointer `ps'. This is perfectly correct behavior, which supports information hiding. To make the meaning of `struct s' globally known, you need to declare it in a global context.