Mail Archives: djgpp/1999/05/21/20:52:37
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
- Raw text -