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.
Hi. I'm using C6000 compiler.
I'm trying to compile a project where I have the files and sample content:
utility.h:
int globalvar;
utility.c:
#include utility.h
void func1() {
globalvar = 1;
}
main.c:
#include utility.h
int main(void) {
...
}
in the linking process it gives the error:
error #10056: symbol "globalvar" redefined: first defined in "./src/main.obj"; redefined in "./src/utility.obj"
I have this same code compiled for other processors, and they link fine.
How do I tell C6000 not to try redefine the global vars?
Thanks in advance.
Please see http://c-faq.com/decl/decldef.html . Pay careful attention to the part about how a common model allows multiple definitions. That is probably how the other compilers work. The C6000 compiler does not have this feature. Thus, you have to insure there is only one definition of globalvar present.
A note to users of the TI ARM and MSP430 compilers ... These compilers do support the common data feature, which means the above test case works with no changes.
Thanks and regards,
-George
Thanks, George. It worked.
Had to do it the right way: declare vars on .c files and extern on .h files.