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.
Tool/software: TI C/C++ Compiler
Customer found a defined global variable had also been already assigned in the CMD file in their firmware, but there was no compiler errors reported. Will it be an issue? Thank you.
For now, I presume you use COFF ABI, and not the recently introduced EABI.
This symbol written in C ...
/* C file */ int global_variable;
... and this symbol written in the linker command file ...
/* linker command file */ global_variable = 0xa000;
... are different symbols. Search for those symbols in the linker map file. Both symbols are present, with different values. The symbol from the C file is written _global_variable in the automatically generated assembly file. An underscore character is added to the beginning.
Aki Li said:Will it be an issue?
If the user intends for these symbols to be different, then no.
If you change to EABI, it won't work. In EABI, a symbol is written the same way everywhere. The underscore character is not added to the beginning. In that case, those symbols are the same, and you see an error when you build.
Thanks and regards,
-George
George,
Thank you. Customer said they already add an underscore character before the variable in the CMD, i.e, _global_variable. And they found it could not work, unless they disabled the variable in C file.
Aki Li said:they found it could not work
Please give a detailed description of what happens when it does not work. What does the customer see? What does the customer expect instead?
Please search the C28x assembly tools manual for the sub-chapter titled Using Linker Symbols in C/C++ Applications. Perhaps that documentation will solve the problem.
Thanks and regards,
-George
Hi, George
if we define the variable in the linker command file as _global_variable, how do the compiler deal with the conflict? there are the one address of the global_variable or the two address of the global_variable?
thank you.
Mark-Lu said:if we define the variable in the linker command file as _global_variable, how do the compiler deal with the conflict?
If you define it in C code as ...
extern int global_variable;
... then there is no conflict. They are are viewed as the same symbol.
If you define it in C code as ...
int global_variable; /* no extern */
Then you get an error diagnostic when you link. The linker complains about multiple definitions of the same symbol.
Thanks and regards,
-George