I'm trying to setup a multilanguage GUI for an application running on AM335x processor; developing in CCS 6.0.1 and using TI compiler 5.1.8. The concept is to get enumerated dictionary arrays and then switch current dictionary pointer to one of them, so that Im able to use enums that make sense.
enum dictionary_indexes {
name,
surname,
phone
}
const char *dictionary_en[60];
dictionary_en[name] = "Your name";
dictionary_en[surname] = "Your surname";
//and so on
Unfortunately, CCS wont compile such code. Itll only allow array initialized at the moment of declaration:
//compiles nicely:
const char * const teststring[] = {
"String1",
"String2",
};
//doesn't compile:
const char *teststring2[2];
teststring2[0]="Hello";
teststring2[1]="World";
Such code results in an error
a value of type "char [6]" cannot be used to initialize an entity of type "int [0]"
and so for every array entry.
Am I missing something here? I've used such code in the past and worked fine. Is it a compiler issue with TI, or is the issue specific for the processor? The code that is supposed to be working is based on this thread: How do I create an array of strings in C?
The teststring2 has to be a global variable, but its init can't. A little rafactor to enclose the init in an executable funciton brings relief and proper compilation, as suggested by @barakmanos.