emcphers@manu.cs.vt.edu (Frank McPherson) (06/08/91)
I'm attempting to add a menu to a program I'm in the process of writing.
I have run into a problem. I can't get my initializations of those
structures past the compiler for some reason. Here's what the
declarations look like:
struct IntuiText quit_text =
{
0,1, /* FrontPen, BackPen */
JAM1, /* DrawMode */
0,1, /* LeftEdge, TopEdge */
NULL, /* ITextFont */
(UBYTE *) "Quit", /* IText */
NULL /* NextText */
};
struct MenuItem quit_item =
{
NULL, /* NextItem */
0,0, /* LeftEdge, TopEdge */
150,10, /* Width, Height */
(ITEMTEXT| /* Flags */
ITEMENABLED|
HIGHNONE),
0L, /* MutualExclude */
(APTR) &quit_text, /* ItemFill */
NULL, /* SelectFill */
NULL, /* Command (keyboard equiv.) */
NULL, /* SubItem */
0 /* NextSelect */
};
struct Menu project_menu =
{
NULL, /* NextMenu */
0,0, /* LeftEdge, TopEdge */
70,10, /* Width, Height */
MENUENABLED, /* Flags */
(UBYTE *) "Project", /* MenuName */
(APTR) &quit_item /* FirstItem */
};
I'm trying to declare a menustrip with only one menu (called Project)
and a single selection (called Quit). Both lines which have (APTR)
type casts give me the following error with SAS/C 5.10A:
Error 20: invalid constant expression
I'm stuck. Any help will be appreciated. Please reply via email to
avoid wasting bandwidth with what is probably a silly misake on my
part. If you need more of the code in order to help, please ask me
for it.
Thanks in advance for your help!
-- Frank McPherson INTERNET: emcphers@manu.cs.vt.edu --steve@wildcat.UUCP (Steve Holland) (06/16/91)
>In article <28728@know.pws.bull.com> emcphers@manu.cs.vt.edu (Frank McPherson) writes: > >I'm attempting to add a menu to a program I'm in the process of writing. >I have run into a problem. I can't get my initializations of those >structures past the compiler for some reason. Here's what the >declarations look like: > >struct IntuiText quit_text = > { > 0,1, /* FrontPen, BackPen */ > JAM1, /* DrawMode */ > 0,1, /* LeftEdge, TopEdge */ > NULL, /* ITextFont */ > (UBYTE *) "Quit", /* IText */ > NULL /* NextText */ > }; >struct MenuItem quit_item = > { > NULL, /* NextItem */ > 0,0, /* LeftEdge, TopEdge */ > 150,10, /* Width, Height */ > (ITEMTEXT| /* Flags */ > ITEMENABLED| > HIGHNONE), > 0L, /* MutualExclude */ > (APTR) &quit_text, /* ItemFill */ ^^^^^^^^^ > NULL, /* SelectFill */ > NULL, /* Command (keyboard equiv.) */ > NULL, /* SubItem */ > 0 /* NextSelect */ > }; >struct Menu project_menu = > { > NULL, /* NextMenu */ > 0,0, /* LeftEdge, TopEdge */ > 70,10, /* Width, Height */ > MENUENABLED, /* Flags */ > (UBYTE *) "Project", /* MenuName */ > (APTR) &quit_item /* FirstItem */ ^^^^^^^^^ > }; > >I'm trying to declare a menustrip with only one menu (called Project) >and a single selection (called Quit). Both lines which have (APTR) >type casts give me the following error with SAS/C 5.10A: >Error 20: invalid constant expression You can't initialize to a variable in C. Rather, initialize it as NULL and fill it in later. >I'm stuck. Any help will be appreciated. Please reply via email to >avoid wasting bandwidth with what is probably a silly misake on my >part. If you need more of the code in order to help, please ask me >for it. > >Thanks in advance for your help! > >-- Frank McPherson INTERNET: emcphers@manu.cs.vt.edu -- -- ----------->Steve Holland<----------- Internet: wildcat!steve@alphalpha.com| "I never let my schooling get in the USENET: ...!alphalpha!wildcat!steve | way of my education" -Mark Twain
jleonard@pica.army.mil (06/20/91)
>In article <steve.4732@wildcat.UUCP> Steve Holland <wildcat!steve> writes: >>In article <28728@know.pws.bull.com> emcphers@manu.cs.vt.edu (Frank McPherson) writes: >>struct IntuiText quit_text = >> { >> 0,1, /* FrontPen, BackPen */ >> JAM1, /* DrawMode */ >> 0,1, /* LeftEdge, TopEdge */ >> NULL, /* ITextFont */ >> (UBYTE *) "Quit", /* IText */ +++++++ This is your problem, try initialising an array of UBYTE to "QUIT" and then assigning IText to the address of the UBYTE array. >> NULL /* NextText */ >> }; >>struct MenuItem quit_item = >> { >> NULL, /* NextItem */ >> 0,0, /* LeftEdge, TopEdge */ >> 150,10, /* Width, Height */ >> (ITEMTEXT| /* Flags */ >> ITEMENABLED| >> HIGHNONE), >> 0L, /* MutualExclude */ >> (APTR) &quit_text, /* ItemFill */ > ^^^^^^^^^ >> NULL, /* SelectFill */ >> NULL, /* Command (keyboard equiv.) */ >> NULL, /* SubItem */ >> 0 /* NextSelect */ >> }; >>struct Menu project_menu = >> { >> NULL, /* NextMenu */ >> 0,0, /* LeftEdge, TopEdge */ >> 70,10, /* Width, Height */ >> MENUENABLED, /* Flags */ >> (UBYTE *) "Project", /* MenuName */ +++++++++++ Same as above >> (APTR) &quit_item /* FirstItem */ > ^^^^^^^^^ >> }; >> >>I'm trying to declare a menustrip with only one menu (called Project) >>and a single selection (called Quit). Both lines which have (APTR) >>type casts give me the following error with SAS/C 5.10A: >>Error 20: invalid constant expression This is complaining about you trying to stuff "Quit" and "Project" (which are arrays of UBYTE) into a UBYTE *. > You can't initialize to a variable in C. Rather, initialize it as NULL >and fill it in later. You can initialise globals to anything that is known or prototyped at the time the variable/structure is initialised. This includes function pointers, constant expressions (provided type is correct) and pointers to variables/structures. >>-- Frank McPherson INTERNET: emcphers@manu.cs.vt.edu -- >-- > ----------->Steve Holland<----------- > Internet: wildcat!steve@alphalpha.com| "I never let my schooling get in the > USENET: ...!alphalpha!wildcat!steve | way of my education" -Mark Twain ___________________________________________________________________________ |Jeff Leonard Usenet: jleonard@pica.army.mil | | My strength is as the strength of ten because my code is pure. | ---------------------------------------------------------------------------