Sender: nate AT cartsys DOT com Message-ID: <37460064.7B98915E@cartsys.com> Date: Fri, 21 May 1999 17:55:00 -0700 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.5 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Allegro problem References: <3742A477 DOT 41DAF3A3 AT connect DOT ab DOT ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Tom Fjellstrom wrote: > > Hello, > > I've been having this really > annoying problem lately. > > whenever i try to initialize an > allegro gui 'MENU' or 'DIALOG' > struct with a variable or makecol() > i get a fatal error. > > so if I had this var: > char *curly = "i am joe"; > > and this struct: > > DIALOG larry[] = { > { d_text_proc, 0, 0, 0, 0, makecol(255,255,255), makecol(0,0,0), 0, 0, > 0, 0, curly }, > { NULL } > }; > > I get these errors: > > initializer element for `larry[0].fg' is not constant > initializer element for `larry[0].bg' is not constant > initializer element for `larry[0].dp' is not constant As you should. `curly' is a variable and its value can change, so clearly you cannot initialize with it. `makecol' is a function. You can only initialize with values that can be computed at compile time. So you should initialize those fields with zeros or something, then write some code that sets up the values correctly. larry[0].fg = makecol(...); larry[0].dp = curly; > Has any one else had this problem? > I know it doesn't happen when i initialize my > own structs this way. Then presumably your case was different. This is how the C language works. -- Nate Eldredge nate AT cartsys DOT com