I have Declared all my declaration in one file called ADeclaration.h and included this file in all my module C files.
i.e.
i have
MAIN.c (MAIN) Port_IO.c (PORT_IO) STORAGE.c (STORAGE) TEMPERATURE.c (TEMPERATURE) CONVERT.c (CONVERT) UART.c (UART) RTC.c (RTC) I2C.c (I2C) ISR.c(ISR) FLASH.c (FLASH)
All the declaration of this files are in Adeclaration.h
now i am getting my project.M51 with Program Size: data=157.5 xdata=5988 code=11148 LINK/LOCATE RUN COMPLETE. 29 WARNING(S), 294 ERROR(S)
and the target is not created
most of the error are like
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: LOCAL MODULE: STORAGE.obj
If you have:
int my_variable;
in a header file and includes it from multiple c files, you will get problems. Then every c file that includes the header fle will try to create a variable "my_variable", and the linker will be unhappy.
extern int my_variable;
in the header file, then no c file will create any variable with that name, but they will know that somewhere there should exist such a variable. The c code will be happy but the linker will still be unhappy - this time about a missing symbol.
So - in your header file you should write:
and then in one (1) c file you should have a line:
int my_varible;
or maybe:
int my_variable = 127;
Then all c files that includes the header file will know about the existence of the variable. But the linker will find exactly one file that actually creates such a variable.
By the way - this isn't something unique to embedded programming. Any text book about the C programming language will tell you about the use of variables in multiple modules and the use of the "extern" keyword.
I have tried Creating Adeclaration.c File with all declaration
unsigned char global_cnt
and an header file adeclaration.h with
extern unsigned char global_cnt
then included header file in all C file...
but still the error exists
You have anything named LOCAL? Maybe a collision with something in the runtime library.
well i have changed the Local struct to Local1
but still the problem exist
"but still the problem exist"
But has the name reported in the error message changed to Local1 ?
Have you done a text search through all your source files (*.c, *.h, any assember files, etc) for occurrences of the word "local" (or "local1") ?
You have a huge number of errors and warnings there!!
:-0
It is highly likely that many of them will be related!
Don't worry unduly about this one error until you have fixed all the other errors and warnings!
*** ERROR L105: PUBLIC REFERS TO IGNORED SEGMENT SYMBOL: UPDATE_FLAG SEGMENT: ?DT?RTC
how to remove this error
Hi Swapnil,
as Andy mentioned it might be possible that most of the errors are related. So you should do a top-down approach when fixing errors which means: Start with the very first error showing up in the log file, not with the last.
Christian.
i had been given the one file 2000 line code from my company and they asked me to modularized this code. Now i only know the flow of this code.with this when i modularized the code it is compiling but showing error mostly ERROR L104 and ERROR L105
the first error in my log is L104 and the list is endless with the same error ....rest of the error is rectified by me.
only Error 104 is in my list .
and here i am stucked in it.
"i had been given the one file 2000 line code from my company"
Did it build cleanly (ie, no errors, no warnings) originally?
If not, that is clearly something that you need to fix before you do anything else!
"when i modularized the code it is compiling but showing error mostly ERROR L104 and ERROR L105"
So, how did you "modularise" it?
Clearly, whatever you did has introduced these errors - don't you think?!
I doubt I'd lose much money if I bet that the L104s are due to you making the classic mistake of having definitions in your header file(s)...
See: c-faq.com/.../decldef.html And: http://www.keil.com/support/man/docs/bl51/bl51_l104.htm
And the L105s are probably a direct result of the L104s: http://www.keil.com/support/man/docs/bl51/bl51_l105.htm