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.

Compiler: Underscore before variables

Tool/software: TI C/C++ Compiler

Hi expert,

This is a grammar problem.

In CMD file for C2000 devices, we always see these:

#ifdef __TI_COMPILER_VERSION__
	#if __TI_COMPILER_VERSION__ >= 15009000
	.TI.ramfunc : {} LOAD = FLASHD,
						 RUN = RAMLS0 | RAMLS1 | RAMLS2 |RAMLS3,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_SIZE(_RamfuncsLoadSize),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         RUN_SIZE(_RamfuncsRunSize),
                         RUN_END(_RamfuncsRunEnd),
						 PAGE = 0, ALIGN(4)
	#else

We can see there is a underscore before "RamfuncsLoadStart". But in the C file, when we use this, we don't have underscore anymore (if we have, there will be an error). Could you tell me the reason?

void cpu1_init(xtal_freq_t xtal, pll_freq_t pll_freq)
{
        extern uint16_t RamfuncsRunStart;
        extern uint16_t RamfuncsLoadStart;
        extern uint16_t RamfuncsLoadSize;

        //disable_irq();
        DINT;
        disable_dog();
        memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
        sys_flash_ctrl_init();

If there is a document to support the reason will be warmly welcomed.

Thanks

Sheldon

  • It is a convention of the C2000 compiler that all global names written in C, functions and variables, are written in the generated assembly by prepending an underscore.

    Sheldon He said:
    If there is a document to support the reason will be warmly welcomed.

    In the C2000 compiler manual, in the section titled Using Assembly Language Modules With C/C++ Code, there is a bullet which begins ...

    The compiler prepends an underscore ( _ ) to the beginning of all identifiers.

    Note all of the above is correct for COFF ABI.  Starting with compiler version 18.9.0.STS, the C2000 compiler supports an additional ABI named EABI.  It is documented in the same manual.  There are several differences between COFF ABI and EABI.  One difference is that, in EABI, global names are written the same in C and assembly.  The convention of prepending an underscore is not used.

    Thanks and regards,

    -George