Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
October 1, 2011 - 7:12am
|
please helpl me find the mistake: void main(){ sprintf (str,"test %d",123); If i compile it's ok, but when I build the poject it gives out error LINK/LOCATE RUN COMPLETE, 1 ERROR FOUND. what's wrong? |
Hi,
Thanks for your report.
This is a known limitation : The sprintf() function requires that the putchar() function is present in your project. Failing to have it will result in a
linker error 100 : UNRESOLVED EXTERNAL.
This is because the C library is optimized for the overall size of applications, so printf and sprintf have been written as a single piece of code which either copies the emitted characters to a memory buffer (case of sprintf) or emits the characters through putchar (case of printf).
A workaround to this limitation is to add a "dummy" call to putchar in a harmless place in your code.
A good place for placing this dummy "putchar(0)" call is at the bottom of your main() code.
Let us know if you still have some issues on this.
Best Regards,
Thanks Bruno.
I've tried your solution :
But it still causes error:
Hi,
I guess you are not using the Ride7 integrated environment. It would have been taking care of the UART type necessary to your specific microcontroller.
What you must do is add a SCINAME linker directive, for example:
SCINAME(STM8)
This should make it.
BR
Hi, Bruno.
Thanks for your help.
As I said before I use visual develope IDE
I just added SCINAME(STM8) to linker options and it works.
thanks alot.