FabioP
Joined: 26 Oct 2017 Posts: 1
|
const char* with 16bit index |
Posted: Mon Mar 26, 2018 2:12 am |
|
|
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: 19520
|
|
Posted: Mon Mar 26, 2018 3:43 am |
|
|
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). |
|