View previous topic :: View next topic |
Author |
Message |
Alastair Rae
Joined: 19 Jan 2012 Posts: 6
|
Posted: Thu Feb 16, 2012 4:17 pm Post subject: String corruption |
|
|
I'm trying to debug a problem with strings getting corrupted.
I have
Code: |
char PROGMEM string0[] = "test one";
char PROGMEM string1[] = "test two";
char PROGMEM string2[] = "test three";
const PROGMEM char* strings[] = {
string0,
string1,
string2
};
|
but when I try to access these, such as with
Code: | case ACTION_INSERT_MENU:
dbsp("XXX We are here\n");
dbsp("XXX string1 = "); dbs(string1); dbc('\n');
dbsp("XXX strings[1] = "); dbs(strings[1]);dbc('\n');
insert_menu(strings[1]);
|
the strings get messed up. In the debug and on the menu, I get lots of non-ascii chars.
Am I missing something about pointer handling in this environment?
[/code] |
|
Back to top |
|
 |
pz
Joined: 12 Mar 2004 Posts: 1161
|
Posted: Fri Feb 17, 2012 6:49 am Post subject: |
|
|
strings[] is in PROGMEM, so strings[1] cannot be used - compiles assumes RAM. Use rw(&strings[1]) instead. |
|
Back to top |
|
 |
Alastair Rae
Joined: 19 Jan 2012 Posts: 6
|
Posted: Fri Feb 17, 2012 4:50 pm Post subject: |
|
|
pz wrote: | strings[] is in PROGMEM, so strings[1] cannot be used - compiles assumes RAM. Use rw(&strings[1]) instead. |
Thanks. I've now read the Memory page and it makes more sense. |
|
Back to top |
|
 |
|