PlatformIO Community

How does platformio Link -DUSE_FLOATS=1

hello, everyone
I want to print floating points in STC8 ,but I don t know how to correctly add the compilation flag “-DUSE_FLOATS=1”.
my platfromio.ini is list as follow:

platform = intel_mcs51
board = STC8H8K64U
build_flags =

After doing this, I use the sprintf function, and still can only print “NO FLOAT”.
please help me and think very much.

build_flags =


build_flags = -DUSE_FLOATS=1

would be correct.

Where however did you read that that would solve the problem?

With what code does what exact error occur?

The official SDCC manual is as follows

printf() The default printf() implementation in printf_large.c does not support float (except on
ds390), only <NO FLOAT> will be printed instead of the value. To enable floating point output, recompile it
with the option -DUSE_FLOATS=1 on the command line. Use --model-large for the mcs51 port, since this uses a
lot of memory. To enable float support for the pic16 targets, see 4.7.9.

I don t know how to correctly add the compilation flag

I tried this, but it couldn’t

And with

build_flags =  --model-large -DUSE_FLOATS=1


I used the "- -model-large"

Maybe I should send you the complete one

platform = intel_mcs51
board = STC8A8K64D4

build_flags =

extra_scripts =

; upload_speed = 1152000

; change microcontroller
board_build.mcu = stc8a8k64d4

; change MCU frequency
board_build.f_cpu = 24000000L


Yes that looks good, I also devised the same solution. But it still won’t print these floats?

I read that on the SDCC 4.2.3 manual ( that is indeed what one is supposed to do.

PlatformIO uses SDCC 4.2.0. This should be recent enough…

If you want to test it out, download the latest tool chain version from Small Device C Compiler - Browse Files at, install it locally then copy the toolchain files in C:\Users\<user>\.platformio\packages\toolchain-sdcc. So you can test that with 4.2.3.

The current website seems to be only 4.2.0. Where did you find 4.2.3?

Mhmm the documentation I linked to says 4.2.3, I think that is autogenerated. Let’s try the latest snapshot (for windows at Small Device C Compiler - Browse /snapshot_builds/x86_64-w64-mingw32 at