Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuts.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuts!teach0 From: teach0@whuts.UUCP (CTD_STUDENT0.) Newsgroups: net.lang.c Subject: Re: Structure question (problem) Message-ID: <123@whuts.UUCP> Date: Thu, 23-May-85 08:59:40 EDT Article-I.D.: whuts.123 Posted: Thu May 23 08:59:40 1985 Date-Received: Sat, 25-May-85 00:01:22 EDT References: <185@vger.UUCP> Organization: AT&T Bell Laboratories Lines: 44 > Could someone please inform me what the hell I am doing wrong. The > subject is auto-initialization of structures. Here is a simple program > that trys to initialize the stucture, and the associated error > message. If I take one of K&R's examples (pg 124, last half page), > I get the same error. > BTW-This is 4.2bsd. > > ===== > > /* Structure test */ > > #include > > > main() { > > static char *text[] = { "Fred", "Wilma", "Barney", "Betty" }; > struct l { > int a; > int b; > char *c; > int d; > } e = { 0, 1, text[0], 4 }; > > printf("Fred is married to Wilma, Barney to Betty...\n"); > > } > > ===== > % cc t.c > "t.c", line 14: no automatic aggregate initialization > "t.c", line 14: warning: illegal combination of pointer and integer, op = > Aggregates (arrays, structures, unions) can only be initialized if they are declared static or external. A simple: static struct l{ ......... will do. -- Fred Eng AT&T Bell Laboratories