lnDSO150 icon indicating copy to clipboard operation
lnDSO150 copied to clipboard

warning: 'float' is promoted to 'double' when passed through '...' when compiling on windows

Open stokie-ant opened this issue 11 months ago • 3 comments

the full warning:

D:\Projects\lnDSO150\lnArduino\embedded_printf\printf.c: In function '_vsnprintf':
D:\Projects\lnDSO150\lnArduino\embedded_printf\printf.c:769:15: warning: 'float' is promoted to 'double' when passed through '...'
  769 |         idx = _ftoa(out, buffer, idx, maxlen, va_arg(va, FLOAT_SIZE_TYPE), precision, width, flags);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\Projects\lnDSO150\lnArduino\embedded_printf\printf.c:769:15: note: (so you should pass 'double' not 'float' to 'va_arg')
D:\Projects\lnDSO150\lnArduino\embedded_printf\printf.c:769:15: note: if this code is reached, the program will abort

and it does cause the program to abort, instantly.

Using mingw make and the toolchain from https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/tag/v10.2.1-1.1

solved with a SET(PLATFORM_C_FLAGS "-DPRINTF_DISABLE_SUPPORT_FLOAT ") in platformConfig.cmake

This is the first time for me with STM32 development and first time cross compiling with windows so please forgive me if this is my mis-configuration

stokie-ant avatar Jan 27 '25 22:01 stokie-ant

Hi Let me check that one. The main underlying problem is that i'm trying to avoid double completely. The GD32F303/CH32V30X have single float support, so the math lib is very small for them (like 1kB)

As soon as you use one function dealing with doubles, you pull the double math software lib and you increase the code size by 5 to 10kB instantly

mean00 avatar Jan 29 '25 06:01 mean00

I'm not reproducing that one, both with clang & gcc on linux gcc version 11.3.1 20220712 (xPack GNU Arm Embedded GCC x86_64)

mean00 avatar Feb 04 '25 07:02 mean00

It doesn't happen under linux for me either. Only seems to be windows gcc. I'll investigate more but I've fried my stm32 so its on a back burner for now

stokie-ant avatar Feb 04 '25 11:02 stokie-ant