nxp-mcuxpresso / mcux-sdk

MCUXpresso SDK
BSD 3-Clause "New" or "Revised" License
340 stars 149 forks source link

Enforcing -fsingle-precision-constant prohibits defining double constants #175

Closed stefanct closed 8 months ago

stefanct commented 8 months ago

The SDK adds the -fsingle-precision-constant compilation flag even on CPUs that support doubles natively: https://github.com/nxp-mcuxpresso/mcux-sdk/blob/acc105f1e6304bf3a16ebbb503f8882a4daa1408/tools/cmake_toolchain_files/mcux_config.cmake#L34 In standard C, floating-point literals without a suffix like 3.14 have type double and the f suffix as in 3.14f indicates type float. There is no dedicated suffix to enforce the literal type to double - no suffix means double in the standard. Therefore, adding the mentioned parameter makes it impossible to set double-typed constants, which might be quite surprising as it directly violates the ISO C standard. I think the parameter is ill-fated in general (it hides coding mistakes) but actually hazardous in the case of double-enabled FPUs.

zejiang0jason commented 8 months ago

Thanks @stefanct , will remove them.