Mail Archives: djgpp/1998/03/20/10:31:39
tob AT world DOT std DOT com wrote:
>
> Lee <jag*NOSPAM*@pangea.ca> writes:
> > However, the following code produces the error:
> > initializer element for `main_dialog[5].dp' is not constant
> >
> > *code*
> > DIALOG main_dialog[] =
> > {
> > /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key)
> > (flags) (d1) (d2) (dp) */
> > ...some stuff....
> > { d_bitmap_proc, 0, 0, 0, 0, 0, 0, 0,
> > 0, 0, 0, mydat[LOGO].dat},
> > ...some other stuff
> > };
> > *end code*
>
> It means what it says, the initializer for `main_dialog[5].dp'...
>
> > { d_bitmap_proc, 0, 0, 0, 0, 0, 0, 0,
> > 0, 0, 0, mydat[LOGO].dat},
> ^^^^^^^^^^^^^^^ main_dialog[5].dp
>
> ...is not constant. And it isn't. The compiler can't reduce
> mydat[LOGO].dat to a constant pointer at compile time. You have to
> initialize that element by hand.
>
> Tom
I think that the original code will work if it is
within a function body ( I assume it is a static variable
as written). If you need a static global create the dialog
with all elements except .proc to null then in main() use
main_dialog.dp=mydat[LOGO].dat.
An aside- Ive been working with allegro dialogs and
found it very useful to convert the code to C++ so
the dialog functions such as do_dialog use a DIALOG **
so the paticular dialogs can be created by new() and Initializes
by a constuctor.
Charles Terry
- Raw text -