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 support@ccsinfo.com

const char* with 16bit index

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



Joined: 26 Oct 2017
Posts: 1

View user's profile Send private message

const char* with 16bit index
PostPosted: Mon Mar 26, 2018 2:12 am     Reply with quote

Hi, to all.
I've found a problem with a const string table:
Code:

const char Testi[][*] =

"English",      "Menu",         "User",         "Info",         "Technical",
"Manufac.",     "Password",     "Function",     "Set Sani",     "Set Warm",
//10
"Date-Time",    "U04",          "T. Unit",      "U06",          "Retro",
"U07",          "Prog",         "U09",          "Lang",         "San",
//20
"San+M",        "San/Heat",     "San+M/Heat",   "Heat",         "Off",
"\X7CC",        "\X7CF",        "Always",       "On Err",       "Mon",
.....
};

The number of "string" are around 350....
If on my code I try to "bring" a string that have index higher than 0x00FF eg:
Code:

char Dsp_Txt[50];             /* RAM Buffer */
strcpy(Dsp_Txt,Testi[262]); //0x0106 index

Dsp_Txr was set with "0x0006" index string -> "Password"

Is this a limit of compiler or there are some mistake on my code?

I'm using PCC compiler (V4.135) on Microchip PIC18F67K22

Many thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 13264

View user's profile Send private message

PostPosted: Mon Mar 26, 2018 3:43 am     Reply with quote

You are just asking too much.

The [*] construct that handles variable length strings, has a number of elements limit. If instead you declare:
#device PASS_STRINGS=IN_RAM

and give the array a fixed size line:

const char Testi[][12] =

or however many characters your largest item needs, you will find it'll then work. Even better like this you don't have to copy the ROM declaration to RAM, but can print directly from the ROM:

printf("%s\n", Testi[262]);

Downside it it'll use a little more ROM (but not that much).
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