i have defined an array in header file "Variables.h" and include it to source files. extern char LCD[11] = {0xF6, 0xC0, 0x6E, 0xEA, 0xD8, 0xBA, 0xBE, 0xE0, 0xFE, 0xFA, 0x00};
when am trying to compile i get the next message:
Build target 'Target 1' assembling LPC2300.s... compiling Main.c... compiling Interrupts.c... compiling Init.c... compiling LCD_ML1001.c... linking... Second Counter + TI8148.axf: Error: L6200E: Symbol LCD multiply defined (by interrupts.o and main.o). Second Counter + TI8148.axf: Error: L6200E: Symbol LCD multiply defined (by init.o and main.o). Second Counter + TI8148.axf: Error: L6200E: Symbol LCD multiply defined (by lcd_ml1001.o and main.o). Second Counter + TI8148.axf: Not enough information to list image symbols. Second Counter + TI8148.axf: Not enough information to list the image map. Second Counter + TI8148.axf: Finished: 2 information, 0 warning and 3 error messages. Target not created
"So is it one that does treat multiple definitions as a single definition, but warns you that it's done so?"
it is compiler specific. some compilers wouldn't complain about multiple but identical defines. others do.
'C' itself copes with multiple definitions of an object in a single compilation unit - see "tentative definitions".
The preprocessor allows multiple but identical #defines.
The error reported by the OP was a Linker error - not a compiler error.
The potential problem with the linker treating multiple but identical definitions as the same object is that it can't tell whether that was the programmer's intention or not - hence my opinion that a warning should, at least, be given.
I guess the counter argument is that the mistake illustrated here is so common that it is quite likely that it was, in fact, the programmer's intention...?
No, as a matter of fact, it doesn't. The whole business about tentative definitions exists so there will not be multiple definitions of the the same object, even in a single translation unit. This is achieved by specifying that something like
int foo;
is not, in and of itself, a bona fide definition. It's a declaration that may turn into a definition under certain conditions, to be resolved as the compilers proceeds with its work on the module. That's why it's called a tentative, i.e. a "may-be" definition. You can have multiple instance of that line in a single source file, and only one of them will actually be a definition. The others silently demote into declarations.
Even inside a single source file you can't have multiple actual definitions.
int foo=1; int foo=1;
This is not allowed to compile without complaint.
There is a common extension in this area where the tentative definition mechanism is widened from individual translation units to the whole program. I.e. tool chains supporting this extension (in the setting you're using) will merge multiple tentative-turned-actual definition into a single object at link time. But they won't do it for initialized definitions.