<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to add compiler options in nRF Connect SDK / implicit conversion from &amp;#39;float&amp;#39; to &amp;#39;double&amp;#39;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117365/how-to-add-compiler-options-in-nrf-connect-sdk-implicit-conversion-from-float-to-double</link><description>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 &amp;#39;float&amp;#39; to &amp;#39;double&amp;#39; to match other operand of binary expression [-Wdouble-promotion] 
 The warning did not appear</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 20 Feb 2025 11:18:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117365/how-to-add-compiler-options-in-nrf-connect-sdk-implicit-conversion-from-float-to-double" /><item><title>RE: How to add compiler options in nRF Connect SDK / implicit conversion from 'float' to 'double'</title><link>https://devzone.nordicsemi.com/thread/523873?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2025 11:18:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26897f0b-cc29-4b8a-936e-2b962995c4f7</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;Oh... this means that our v2.5.3 based implementation runs inefficiently, even without the warnings. Good to know.&lt;/p&gt;
&lt;p&gt;Thanks for the feedback!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add compiler options in nRF Connect SDK / implicit conversion from 'float' to 'double'</title><link>https://devzone.nordicsemi.com/thread/515419?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2024 10:08:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5454cfae-5e81-4856-9b0e-476d6f357770</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With Zephyr v3.6.0 and newer, this was added as a default warning flag:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/releases/release-notes-3.6.html"&gt;https://docs.zephyrproject.org/latest/releases/release-notes-3.6.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Added -Wdouble-promotion as a default warning when compiling to warn developers with single-precision floats easily being promoted to double-precision.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A typical function that emits such a warning is printf (and variants):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/28097564/why-does-printf-promote-a-float-to-a-double"&gt;https://stackoverflow.com/questions/28097564/why-does-printf-promote-a-float-to-a-double&lt;/a&gt;&lt;/p&gt;
[quote user=""]&lt;p&gt;Later, I found another instruction that worked:&lt;br /&gt;&lt;code&gt;target_compile_options(app PRIVATE -fsingle-precision-constant)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;You can also append using CONFIG_COMPILER_OPT=&amp;quot;-f...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]&lt;strong&gt;Question 2&lt;/strong&gt;: What is the difference between&lt;code&gt; add_compile_options()&lt;/code&gt; and &lt;code&gt;target_compile_options()&lt;/code&gt;? Why did the first instruction not work?[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To my understanding, add_compile_options() works on a directory level, and not a target level. Ordering comes into play, and thus using a command to set it to the target is often recommended.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>