Arduino: printf/fprintf prints question mark instead of float

后端 未结 4 914
别跟我提以往
别跟我提以往 2020-12-06 18:32

I have the following code for an Arduino sketch:

#include 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
static FILE lcdout = {0} ;

static          


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 19:03

    The GNU toolchain for AVRs (which is included with the Arduino IDE) uses a "minified" version of the C standard library by default, in which, for example, the floating-point support is reduced/taken away from formatted I/O functions (just in order printf() to fit in the few kBytes long storage of the chip.)

    If you want this to work, you have to link agains another library containing the normal version of printf(), by using the -Wl,-u,vfprintf -lprintf_flt linker flags.

提交回复
热议问题