avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Text in .text areas (was AVR gcc port)


From: Theodore A. Roth
Subject: Re: [avr-gcc-list] Text in .text areas (was AVR gcc port)
Date: Sun, 18 Jan 2004 10:58:59 -0800 (PST)

On Sun, 18 Jan 2004, J.C. Wren wrote:

> Theodore A. Roth wrote:
>
> >
> >> On Sun, 18 Jan 2004, J.C. Wren wrote:
> >>
> >>
> >>
> >>>    Assuming one has the structure below, how does one declare the text
> >>> in the structure to be placed in .text instead of .data?  I've figured
> >>> out how to obtain .text placement for strings passed in functions, but
> >>> that (as expected, based on the macro definition) gives errors for text
> >>> in structures.
> >>>
> >>>    --jc
> >>>
> >>> typedef struct commandList_s
> >>> {
> >>>   PGM_P command;
> >>>   void (*handler) (void);
> >>>   PGM_P help;
> >>> }
> >>> commandList_t;
> >>>
> >>> //
> >>> //
> >>> //
> >>> PROGMEM commandList_t commandList  [] =
> >>> {
> >>>   { "?",               cmd_help,         "This help list" },
> >>>   { "version",         cmd_version,      "Display version" },
> >>>   { NULL,              NULL,             NULL }
> >>> };
> >>>
> >>
> >>
> >> Here's a structure I use in one of my projects:
> >>
> >> struct menuitem
> >> {
> >>    FP_MenuItemHandler handler; /**< Function called to handler selected
> >>                                     item. */
> >>    const char * PROGMEM desc;  /**< Text description of menu item.
> >> Must point
> >>                                     to a string in program space. */
> >> };
> >>
> >> The struct lives in program space (.text) and when needed is copied to
> >> sram.
> >>
> >> Hope that helps.
> >>
> >> Ted Roth
> >>
> >>
> > Sorry, when I created the message I did it via a reply, so I've
> > corrected the topic.
> >
> > Unfortunately, this doesn't help :)  I want to keep the structure in
> > .text.  Basically, everything is a constant.  This all worked under
> > ICC, and I was trying to port it to GCC.
> >
> > I've tried a number of things, and keep running into problems with
> > pointers (seemingly) refusing to dereference correctly when items are
> > in .text.   In the example above, I want to keep the help text in
> > .text, and I can't determine how to declare it in the instantiation of
> > the structure.  In the disassembly, the structure is being placed in
> > .text, but the pointers are still to .data , inspite of the "PGM_P
> > help" or "const char * PROGMEM help"

Does this help?

  http://jubal.westnet.com/AVR/doc/avr-libc-user-manual/FAQ.html#faq_rom_array

There's not much difference between array and struct in this case.

Ted Roth


reply via email to

[Prev in Thread] Current Thread [Next in Thread]