Author Topic: Help getting around this error Please!  (Read 1224 times)

0 Members and 1 Guest are viewing this topic.

Offline kgavionicsTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: ca
Help getting around this error Please!
« on: November 12, 2023, 02:19:46 am »
Hello guys
I'm trying to use this library in my project, but I got stuck how to implement the function _putchar (see error screenshot below)
https://github.com/mpaland/printf

Can someone tell me how to make this library work, please!
Thanks in advance!
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17059
  • Country: fr
Re: Help getting around this error Please!
« Reply #1 on: November 12, 2023, 02:27:34 am »
If you're not actually using printf(), but string variants of it (like snprintf()), you can just write a stub _putchar() - place it anywhere convenient in a source file - like so:

Code: [Select]
int _putchar(char c)
{
    return 1;
}

Later on, if you also want to use printf() directly and redirect output to anything (UART, your LCD, whatever), you can just fill this stub function with the code that sends one char to the corresponding peripheral. But if you don't even use printf() directly, no need to bother.

Btw, you should enable C99 support to get rid of the warnings - "useless" warnings are a pollution and will tend to make you ignore more important ones. I don't know your IDE so can't guide further to set this option, but just look at the compilation options and something like that should be there.
« Last Edit: November 12, 2023, 02:29:05 am by SiliconWizard »
 
The following users thanked this post: kgavionics

Offline kgavionicsTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: ca
Re: Help getting around this error Please!
« Reply #2 on: November 12, 2023, 01:22:46 pm »
Merci Beaucoup SiliconWizard it's all sorted out now!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf