🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5562

Re: scope of a structure tag

#5562
From: Doug Gwyn
Date: Sat, 07 Jan 1989 01:54
22 lines
1202 bytes
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.
Technical Details
Message-ID: <9303@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!haven!adm!smoke!gwyn
References: <18799@agate.BERKELEY.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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) <gwyn>)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 22