🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #51712

Re: Problem initializing a structure array

#51712
From: Marek MAKOWSKI
Date: Fri, 16 Apr 1993 11:44
37 lines
1691 bytes
Keith Mason (keith@netcom.com) wrote:
: I have a piece of code that looks like this:
: 
:   typedef struct _item {
:     char *a;
:     char *b;
:   } item;
: 
:   item x[2] = {
:     "One",  "Two",
:     "Three, "Four"
:   };
: 
: And I get back 
: 
:    file.c:9: warning: aggregate has a partly bracketed initializer
:    file.c:9: warning: aggregate has a partly bracketed initializer
:    file.c:9: warning: aggregate has a partly bracketed initializer
:    file.c:9: warning: aggregate has a partly bracketed initializer
: 
: What am I doing wrong here?  And why isn't is correct?
: 
Initialization should read:
  item x[2] = {		
  // Note, that 2 is not necessary,
  // item x[] = {
  // would be also OK
     {"One",  "Two"},
     {"Three, "Four"}
  };

Marek Makowski
-- 
                  Marek Makowski  | Email: marek@iiasa.ac.at
         International Institute  | Phone: +43 02236 71.5210
     for Applied System Analysis  | Fax:   +43 02236 71.313
       A-2361 Laxenburg, Austria  | Telex: 079137 iiasa a
Technical Details
Message-ID: <1993Apr16.114433.4042@iiasa.ac.at>
Path: arc1-ca.pugleaf.net!gmd.de!ira.uka.de!sol.ctr.columbia.edu!howland.reston.ans.net!noc.near.net!uunet!news.univie.ac.at!iiasa.ac.at!marek
References: <keithC5K3A3.Eq9@netcom.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,ffcc861fa54e6e8a
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-04-16 04:58:54 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!ira.uka.de!sol.ctr.columbia.edu!howland.reston.ans.net!noc.near.net!uunet!news.univie.ac.at!iiasa.ac.at!marek
From: marek@iiasa.ac.at (Marek  MAKOWSKI)
Subject: Re: Problem initializing a structure array
Message-ID: <1993Apr16.114433.4042@iiasa.ac.at>
Organization: IIASA, Laxenburg, Austria
X-Newsreader: TIN [version 1.1 PL6]
References: <keithC5K3A3.Eq9@netcom.com>
Date: Fri, 16 Apr 1993 11:44:33 GMT
Lines: 37