How to automatically eliminate double-precision math from generated code?

时间:2019-04-23 15:08:05

标签: floating-point arm embedded clang precision

In our embedded project, targeted for the ARM Cortex M* cores, we are using the ARM clang-based toolchain (v6). We use float type for our floating-point math. As we try to minimize footprint, we found out that some space is taken by unnecessary double<->float conversions.

The source of some of those conversions was the use of literals not including the f specifier (e.g., use 12.34 instead of 12.34f). To eliminate that, I am looking for a compiler option that uses float type by default. Looking at the compiler documentation and at the general clang help, I could not find any.

Is there any option (command option, pragma, attribute, etc.) that can achieve that goal?

1 个答案:

答案 0 :(得分:1)

-fsingle-precision-constant是您正在寻找的,尽管我个人认为应该避免使用,而是使用显式强制转换。

相关问题