Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.std.c Subject: Re: scope of a structure tag Keywords: structure tag scope Message-ID: <9303@smoke.BRL.MIL> Date: 7 Jan 89 01:54:53 GMT References: <18799@agate.BERKELEY.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 22 In article <18799@agate.BERKELEY.EDU> holub@violet.berkeley.edu () writes: -I'm confused about the scope of a structure tag. Is the following legal -in ANSI C: - struct tag1 - { - struct tag2 - { - int a, b; - } x; - } - struct tag3 - { - struct tag2 y; - } -or does the inner structure have to be redefined in tag3? I don't understand your example, which is syntactically invalid. Assuming you put semicolons where they belong and that the two "outer" structures are declared within the same scope (the same file, block, or function prototype, depending on the context), then the first "struct tag2" is still in scope when the second one is encountered, so it is a complete type at that point.