This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Unable to put strings in a table after initialisation

Hi,

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?

  • Dawid,

    This question is actually more specific to Code Gen than TI-RTOS, so I have moved it over to the Compiler forum so it can receive a faster response.

  • I'm confused about what you are trying to do here.  You can't have an expression a statement at the global scope, you must put it inside a function:

    const char *teststring2[2];
    void init()
    {
    teststring2[0]="Hello";
    teststring2[1]="World";
    }

    The C language doesn't allow you to specify initializers anywhere but the definition of a variable.  What compiler were you using that would allow the code you've shown?  Is the posted example perhaps an oversimplified cutdown from the actual code you are using?


    [ statement, not expression -- Archaeologist ]