Skip to main content
PCu1
Senior
June 10, 2020
Question

my own printf

  • June 10, 2020
  • 3 replies
  • 1519 views

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

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
June 10, 2020

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Pavel A.
June 10, 2020

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
PCu1Author
Senior
June 11, 2020

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