cancel
Showing results for 
Search instead for 
Did you mean: 

my own printf

PCu1
Senior

Hi,

I use my own printf(printf, snprintf...) in STM32 since many years.

In atollic I added -fno-builtin-fprintf -fno-builtin-printf -fno-builtin-sprintf in the compiler option.

Now with Cube IDE I do the same but the linker tells me that there are two definitions of some functions related to printf.

I checked with multiple options without success.

I'm using C and C++ because I'm working with touchGFX.

Any idea?

Thank you

Pierre

3 REPLIES 3

Scan the libraries it is pulling and where the printf() comes from, then use a librarian tool to remove the unwanted functions if you can't otherwise eliminate the library or object in question.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

Maybe the little known GNU linker trick with "wrapped" functions can help.

Add options -Xlinker --wrap=printf -Xlinker --wrap=sprintf

and #define printf __wrap_printf

--pa

PCu1
Senior

Thank you for yours answers.

Finally I renamed all the functions in my printf file with "Trace_" prefix.

Because I call it via a macro (to enable/disable debug console), I had only one line to change.

It stays clean.

Pierre