How to add compiler options in nRF Connect SDK / implicit conversion from 'float' to 'double'

Hi,

I just switched from nRF Connect SDK v2.5.3 to v2.8.0. With the new SDK, I get very many warnings called:
implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]

The warning did not appear in v2.5.3.

I found out that there is a gcc compiler option called -fsingle-precision-constant which would fix the problem.

Question 1: Why does this warning appear in v2.8.0 but not in v2.5.3? Was the default interpretation for constants changed in the new SDK? (numbers without explicit type information interpreted as float in v2.5.3 and as double in v2.8.0?)

Then, I tried adding the option with the following line in CMakeLists.txt, which did not help:
add_compile_options(-fsingle-precision-constant)

Later, I found another instruction that worked:
target_compile_options(app PRIVATE -fsingle-precision-constant)

Question 2: What is the difference between add_compile_options() and target_compile_options()? Why did the first instruction not work?

Best regards,
Michael

Parents Reply Children
No Data
Related