bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

String corruption

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
Alastair Rae



Joined: 19 Jan 2012
Posts: 6

PostPosted: Thu Feb 16, 2012 4:17 pm    Post subject: String corruption Reply with quote

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
View user's profile Send private message
pz



Joined: 12 Mar 2004
Posts: 1161

PostPosted: Fri Feb 17, 2012 6:49 am    Post subject: Reply with quote

strings[] is in PROGMEM, so strings[1] cannot be used - compiles assumes RAM. Use rw(&strings[1]) instead.
Back to top
View user's profile Send private message
Alastair Rae



Joined: 19 Jan 2012
Posts: 6

PostPosted: Fri Feb 17, 2012 4:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group