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

Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?

Hi,

I can not get through with ROM-based constants.

When I put a definition:

const char txtParcer_OK[] = "ok! this is sample message ...";

the compiler resides the message in RAM area. I need ROM area.

I use µVision V4.20.03.0
Tool Version Numbers:
Toolchain: MDK-ARM Standard Version: 4.20
Toolchain Path: BIN40\
C Compiler: Armcc.Exe V4.1.0.644
Assembler: Armasm.Exe V4.1.0.644
Linker/Locator: ArmLink.Exe V4.1.0.644
Librarian: ArmAr.Exe V4.1.0.644
Hex Converter: FromElf.Exe V4.1.0.644
CPU DLL: SARMCM3.DLL V4.20
Dialog DLL: DARMCM1.DLL V1.7.0.0
Target DLL: Bin\Nu_Link.dll V1.18
Dialog DLL: TARMCM1.DLL V1.06

Best regards,
Alex.

Parents
  • Not at all!

    #define  const
    

    It just means that the 'const' keyword was effectively stripped from the source code by the preprocessor.
    Since 'const' was purely optional in all the cases tried, there was nothing to warn about!

    eg,

    const char acText[]= "Hallo";
    


    just becomes

    char acText[]= "Hallo";
    


    and

    static const acText[]= "...";
    


    just becomes

    static acText[]= "...";
    


    and

    const char txtParcer_OK[] = "ok! this is sample message ...";
    


    just becomes

    char txtParcer_OK[] = "ok! this is sample message ...";
    

    BTW: There is nothing in the 'C' language definition that requires the compiler to put const items into read-only memory...

Reply
  • Not at all!

    #define  const
    

    It just means that the 'const' keyword was effectively stripped from the source code by the preprocessor.
    Since 'const' was purely optional in all the cases tried, there was nothing to warn about!

    eg,

    const char acText[]= "Hallo";
    


    just becomes

    char acText[]= "Hallo";
    


    and

    static const acText[]= "...";
    


    just becomes

    static acText[]= "...";
    


    and

    const char txtParcer_OK[] = "ok! this is sample message ...";
    


    just becomes

    char txtParcer_OK[] = "ok! this is sample message ...";
    

    BTW: There is nothing in the 'C' language definition that requires the compiler to put const items into read-only memory...

Children