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.

TMS320F28379D: v22.6.1.LTS compiler not catching variable redefinitions in the same source file

Guru 20075 points

Part Number: TMS320F28379D

Tool/software:

Please see the attached file containing the project that highlights the issue.

TestVariableRedefinition.zip

In my actual code, I am using the #pragma LOCATION and RETAIN directives with over 7000 variables. 

Example code with #pragma LOCATION and RETAIN directives is shown below. 

The compiler doesn't catch the variable redefinition for this situation.

int xyz;

#define BASE 0xB000

#pragma LOCATION(abc,BASE+7000)
#pragma RETAIN(abc)
int abc;

#pragma LOCATION(abc,BASE+8000)
#pragma RETAIN(abc)
int abc;

int main(void)
{
    abc++;

    xyz = abc;
    
    return 0;
}

  • This code gets no diagnostics ...

    int abc;
    int abc;

    Initialize both of the variables ...

    int abc = 0;
    int abc = 0;

    Then a diagnostic similar to ...

    "f2.c", line 2: error: variable "abc" has already been initialized

    .... is issued.

    Adding the LOCATION and RETAIN pragmas does not change things.

    For a deeper explanation, please see this page (not from TI).

    Thanks and regards,

    -George

  • Ok, I guess I will have to accept that is the way it works, but I would think it would be better to generate an error for the case when two identifiers with the same name occur in the code, especially when #pragma LOCATION() is used.