Path: utzoo!attcan!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.JUNET (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: Declaration puzzler (another old question?) Message-ID: <10031@socslgw.csl.sony.JUNET> Date: 6 Oct 88 01:55:54 GMT References: <30091@oliveb.olivetti.com> Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 37 In article <30091@oliveb.olivetti.com>, chase@orc.olivetti.com (David Chase) writes: > I can't figure out how to declare the type of an array with (say) 10 > elements, each of which is that array type. That is, I want the > non-error effect of > > typedef foo *(foo[10]); > ^#1 ^#2 The problem is that you're trying to use foo #1 to define foo #2. At the time of using foo (#1), it hasn't been defined yet. Except for structure tags (and other similar tags), you cannot use an identifier before it is declared. > "If T is any C type except void or 'function returning ...,' > the array type 'array of T' may be declared." An undefined identifier is not any C type. > I can succeed, however, if I wrap the array up in a structure, as in > > struct mumble { > struct mumble * children[10]; > }; Yes ... structs are maybe 0th-class citizens, ahead of 1st-class. > I might think that arrays were a second-class type. You also can't do typedef bar bar; or typedef flub flub(); or typedef plunk *plunk; so arrays don't seem to be second to most other types. -- ------------------------------------------------------------------------------- The above opinions are my own. | Norman Diamond If they're also your opinions, | Sony Computer Science Laboratory, Inc. you're infringing my copyright. | diamond%csl.sony.jp@relay.cs.net