|
From: | J.C. Wren |
Subject: | Re: [avr-gcc-list] Text in .text areas (was AVR gcc port) |
Date: | Sun, 18 Jan 2004 13:41:08 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20040110 Thunderbird/0.4 |
Theodore A. Roth wrote:
Sorry, when I created the message I did it via a reply, so I've corrected the topic.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 pointto a string in program space. */ }; The struct lives in program space (.text) and when needed is copied to sram. Hope that helps. Ted RothUnfortunately, 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"--jc
[Prev in Thread] | Current Thread | [Next in Thread] |