Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!udel!mmdf From: jleonard@pica.army.mil Newsgroups: comp.sys.amiga.programmer Subject: Re: Problems with Menu, MenuItem and IntuiText structure declarations Message-ID: <56697@nigel.ee.udel.edu> Date: 19 Jun 91 18:31:24 GMT Sender: mmdf@ee.udel.edu Lines: 74 >In article Steve Holland 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. | ---------------------------------------------------------------------------