Discussion Forum

modifying putchar, and watching the prinf source code

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Amit Alon
Posted
12-Dec-2004 17:37 GMT
Toolset
None
New! modifying putchar, and watching the prinf source code
In http://www.keil.com/support/docs/788.htm you described how to change the putchar function.
I have coppied PUTCHAR.C to the project directory, and added it to the project source files (using uVision2). As soon as I started to re-build the project, the following error occured:


Build target 'Target 1'
compiling SIO.C...
compiling MAIN.C...
compiling PUTCHAR.C...
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _PUTCHAR
MODULE: .\output\PUTCHAR.obj (PUTCHAR)
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_PUTCHAR?PUTCHAR
*** ERROR L118: REFERENCE MADE TO ERRONEOUS EXTERNAL
SYMBOL: _PUTCHAR
MODULE: C:\KEIL\C51\LIB\C51S.LIB (PRINTF)
ADDRESS: 0080H
*** ERROR L118: REFERENCE MADE TO ERRONEOUS EXTERNAL
SYMBOL: _PUTCHAR
MODULE: C:\KEIL\C51\LIB\C51S.LIB (GETCHAR)
ADDRESS: 06E2H
Program Size: data=50.3 xdata=0 code=1780
Target not created

Why ? Where else is putchar defined ? what can I do in order to change putchar ?

Another question is where can I see the source code of printf ?

Thanks,
Amit.
Read-Only
Author
Jon Ward
Posted
12-Dec-2004 17:39 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
What's in the SIO source file?

Jon
Read-Only
Author
Amit Alon
Posted
12-Dec-2004 17:46 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
The following project,
http://www.keil.com/download/docs/intsio2.zip.asp

with minor changes.
Read-Only
Author
Keil Reinhard
Posted
13-Dec-2004 07:32 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _PUTCHAR

means you have a in your project two 'putchar' functions.

'putchar' is already defined in main.c. So you do not need
another module that defines putchar. Therefore remove the
putchar.c module from your project.
Read-Only
Author
Andrew Neil
Posted
13-Dec-2004 07:48 GMT
Toolset
C51
New! Unhelpful Linker Message
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _PUTCHAR
MODULE: .\output\PUTCHAR.obj (PUTCHAR)
As I've noted before, this Linker messages is not very helpful - it is complaining about multiple definitions, but it lists only one definition!
http://www.keil.com/forum/docs/thread1666.asp

It would be far more useful if the message listed all modules containing the offending symbol; eg,
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: VARIABLE_NAME
MODULE: File_Name1.obj (FILE_NAME)
MODULE: File_Name2.obj (FILE_NAME)
Again, Borland manages this.
Read-Only
Author
Keil Reinhard
Posted
13-Dec-2004 07:51 GMT
Toolset
C51
New! RE: Unhelpful Linker Message
Andy, LX51 does this already. It includes a DEFINED: <symbol> information.
Read-Only
Author
Andrew Neil
Posted
13-Dec-2004 08:26 GMT
Toolset
C51
New! RE: Unhelpful Linker Message
"Andy, LX51 does this already."

Jolly good!
Read-Only
Author
Amit Alon
Posted
27-Dec-2004 18:14 GMT
Toolset
C51
New! RE: Unhelpful Linker Message
But not everyone have LX.
What about us ?
Will it stay this way ?
Read-Only
Author
Jon Ward
Posted
13-Dec-2004 08:23 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
Did you remove the putchar and getkey functions from MAIN.C in that example?

Jon
Read-Only
Author
Amit Alon
Posted
27-Dec-2004 18:12 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
Hi,
Sorry for the delay with my response.
Since the error was not clear (didn't point at the relevant place in the code where the problem is), and since the code was downloaded from another place, and was not originally my code, I missed that putchar redefinition in the main.

I am sure that this was the problem, but I didn't have time to verify it.
My task was changed and I didn't need to use main any more (and didn't have time for it).

Anyway, thanks for your kind help.
Best Regards,
Amit A.
Read-Only
Author
Amit Alon
Posted
27-Dec-2004 18:23 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
Another question is where can I see the source code of printf ?

This question was left unanswered.
is it possible to see the source code at all ?

Thanks,
Amit.
Read-Only
Author
Keil Reinhard
Posted
3-Jan-2005 10:17 GMT
Toolset
None
New! RE: modifying putchar, and watching the prinf source code
Sorry, the source code is not public.
Read-Only
Author
Andrew Neil
Posted
3-Jan-2005 11:32 GMT
Toolset
C51
New! RE: modifying putchar, and watching the prinf source code
"Sorry, the source code is not public."

That is to say, the source for Keil's C51 printf implementation is not public. I'm sure you can find some open-source printf implementation(s); eg, SDCC is open-source:
http://sdcc.sourceforge.net/

Of course, that will not be the same as Keil's implementation; no doubt Keil have put a lot of work into optimising their C51 implementation - which is why they're not about to give it away free to all & sundry!
Read-Only
Author
Amit Alon
Posted
3-Jan-2005 12:03 GMT
Toolset
C51
New! RE: modifying putchar, and watching the prinf source code
Just to explain, I wanted to have the source in order to debug a printf command that didn't work.
this problem was solved, but at that time I wanted to perform the printf command step by step for debug purposes.
Amit.
Read-Only
Author
Andrew Neil
Posted
11-Apr-2005 07:37 GMT
Toolset
C51
New! RE: source code
FYI, here is a list of those library functions for which source code is available:

http://www.keil.com/support/man/docs/c51/c51_lib_source.htm

Next Thread | Thread List | Previous Thread Start a Thread | Settings