This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM MDK: Why does this not compile?

Hi,

I hope someone can help. Code with comments explaining
the problem is shown below.

char const char_set1[42] =      {'A','B','C','D','E','F','G','H',
                             'I','J','K','L','M','N','O','P',
                                   'Q','R','S','T','U','V','W','X',
                               'Y','Z','.','-','%','/',':','0',
                                 '1','2','3','4','5','6','7','8','9',' '};



[I then wish to declare a constant pointer to the array]

[The following declaration compiles:]

char const* char_set_arrayA = char_set1;

[But the following declaration fails:]

char const*  char_set_arrayB[]={char_set1};

Eventually I need to pass a series of character set arrays into this declaration but I cannot get it to compile with one array element (char_set1).

I would be grateful for any advice as to why

char const* char_set_arrayB[]={char_set1};

is not accepted by the compiler. The compiler reports

"error #28: expression must have a constant value"

Is the const declaration incorrect?

Thanks

John McLane

Parents
  • The pointer is constant. The data in the array is constant and the arrays are constant.

    I've tried all of the following. They all fail with the same #28 error message.

    const char *char_set_array[] = {char_set1};
    const char * const char_set_array[] = {char_set1};
    char const* const char_set_array[] = {char_set1};
    char* const char_set_array[] = {char_set1};
    char* char_set_array[] = {char_set1};

    Eventually I need to addd further elements to the array
    {char_set1,char_set2,char_set3,char_set4} and am simply trying to get it to compile with one element.

    I am using the following compiler/toolset


    IDE-Version:
    µVision3 V3.63
    Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2008

    License Information:

    Tool Version Numbers:
    Toolchain: RealView MDK-ARM Version: 3.24
    Middleware: RL-ARM Real-Time Library Version V3.24
    Toolchain Path: BIN31\
    C Compiler: Armcc.Exe V3.1.0.939
    Assembler: Armasm.Exe V3.1.0.939
    Linker/Locator: ArmLink.Exe V3.1.0.939
    Librarian: ArmAr.Exe V3.1.0.939
    Hex Converter: FromElf.Exe V3.1.0.939
    CPU DLL: SARM.DLL V3.24
    Dialog DLL: DARMST9.DLL V1.06
    Target DLL: BIN\UL2ARM.DLL V1.43
    Dialog DLL: TARMST9.DLL V1.03

    Thanks

Reply
  • The pointer is constant. The data in the array is constant and the arrays are constant.

    I've tried all of the following. They all fail with the same #28 error message.

    const char *char_set_array[] = {char_set1};
    const char * const char_set_array[] = {char_set1};
    char const* const char_set_array[] = {char_set1};
    char* const char_set_array[] = {char_set1};
    char* char_set_array[] = {char_set1};

    Eventually I need to addd further elements to the array
    {char_set1,char_set2,char_set3,char_set4} and am simply trying to get it to compile with one element.

    I am using the following compiler/toolset


    IDE-Version:
    µVision3 V3.63
    Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2008

    License Information:

    Tool Version Numbers:
    Toolchain: RealView MDK-ARM Version: 3.24
    Middleware: RL-ARM Real-Time Library Version V3.24
    Toolchain Path: BIN31\
    C Compiler: Armcc.Exe V3.1.0.939
    Assembler: Armasm.Exe V3.1.0.939
    Linker/Locator: ArmLink.Exe V3.1.0.939
    Librarian: ArmAr.Exe V3.1.0.939
    Hex Converter: FromElf.Exe V3.1.0.939
    CPU DLL: SARM.DLL V3.24
    Dialog DLL: DARMST9.DLL V1.06
    Target DLL: BIN\UL2ARM.DLL V1.43
    Dialog DLL: TARMST9.DLL V1.03

    Thanks

Children
No data