CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

flash string management

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
heliodoro.alegre



Joined: 20 Nov 2013
Posts: 6

View user's profile Send private message

flash string management
PostPosted: Wed Nov 20, 2013 5:35 am     Reply with quote

I have an old project compiled with C version 3.249
for PIC18F6722 with the code:
Code:

   const char Strings1[5][17] =
   {"  string number 1  ",
     "  string number 2  ",
     "  string number 3  ",
     "  string number 4  ",
     "  string number 4  "};

     int II;

     II = 2;
     printf (Strings1[II]);

worked correctly.
I have try to compile with C version 4.114 for
PIC18F67K22 and I have an error in printf
"Attempt to create a pointer to a constant"

Can anybody help me.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 20, 2013 1:14 pm     Reply with quote

Post a small complete test program that shows the problem. And fix
the problems in your posted code. The strings in your two dimensional
array actually have 19 characters in them, including the spaces at the
beginning and the end. Also, there is a string-terminator byte of 0x00.
So the actual declared row length should be 20, not 17. Also, you
have two strings called "string number 4".

Fix all that and make a test program that I can work with, and maybe
I can solve your problem.

This thread has some sample test programs. Note the general style.
They are very short and complete. The only have code necessary to
show the problem. There is no Wizard code or code to disable timers, etc.
Post a test program for your problem that is similar in overall style:
http://www.ccsinfo.com/forum/viewtopic.php?t=25483
heliodoro.alegre



Joined: 20 Nov 2013
Posts: 6

View user's profile Send private message

PostPosted: Thu Nov 21, 2013 5:50 am     Reply with quote

The problem is con string length. In real code is correct
Code:

 const char Strings1[5][17] =
   {"  string num 1  ",
     "  string num 2  ",
     "  string num 3  ",
     "  string num 4  ",
     "  string num 5  "};

     int II;

     II = 2;
     printf (Strings1[II]);


Code in link you have sent has constant indexes
Code:
glcd_putc(info[1]);
glcd_putc(info[2]);

With constant indexes there is no problem.
The compile error appears when index is a variable.

I have a way to solve the problem, define
Code:
     char RamString[100];

and change printf
Code:
     strcpy (Strings1[II], RamString);
     printf (RamString);

But it is a long work because there is a lot of similar
printf in code.

The question is, C version 3.249 accept my original code
and version 4.114 not.

Can I make 4.114 compatible with this code anyway with
a # pre procesor directive or a command line parameter?
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Thu Nov 21, 2013 6:11 am     Reply with quote

#device PASS_STRINGS=IN_RAM
heliodoro.alegre



Joined: 20 Nov 2013
Posts: 6

View user's profile Send private message

PostPosted: Tue Nov 26, 2013 3:11 am     Reply with quote

This #define
#device PASS_STRINGS=IN_RAM
has not the effects I desired, error persists.

I will go on with the copy in ram method

strcpy (Strings1[II], RamString);
printf (RamString);

In this way I know exctly what compiler is doing.

Thanks you for your interest.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
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