<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to keep/initialize unused variables/constants in MCUXpresso IDE</title>
    <link>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711444#M988</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If nothing in your code is actually using those variables, &amp;nbsp;would suspect that they&amp;nbsp;have actually been removed from your linked application (the used attribute doesn't actually do what you might expect in many cases).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the map file generated by the linker into the Debug (or Release) subdirectory of your project after doing a build to find out what has been discarded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MCUXpresso IDE Support&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Aug 2017 21:03:36 GMT</pubDate>
    <dc:creator>lpcxpresso_supp</dc:creator>
    <dc:date>2017-08-30T21:03:36Z</dc:date>
    <item>
      <title>how to keep/initialize unused variables/constants</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711443#M987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to keep unused constant in my code but I get strange initial value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/28025iAF6646661223C287/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use 3 variations but none of them initialize argument on left side by value 21 :&lt;/P&gt;&lt;P&gt;static&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t prm_sw_version&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; __attribute__((used)) = 21;&lt;/P&gt;&lt;P&gt;static volatile&amp;nbsp; uint32_t prm_sw_version_volatile &amp;nbsp; __attribute__((used)) = 21;&lt;/P&gt;&lt;P&gt;static const&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t prm_sw_version_const&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __attribute__((used)) = 21;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why are left side arguments not initialized ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Aug 2017 12:20:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711443#M987</guid>
      <dc:creator>adamrakam</dc:creator>
      <dc:date>2017-08-30T12:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep/initialize unused variables/constants</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711444#M988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If nothing in your code is actually using those variables, &amp;nbsp;would suspect that they&amp;nbsp;have actually been removed from your linked application (the used attribute doesn't actually do what you might expect in many cases).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the map file generated by the linker into the Debug (or Release) subdirectory of your project after doing a build to find out what has been discarded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MCUXpresso IDE Support&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Aug 2017 21:03:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711444#M988</guid>
      <dc:creator>lpcxpresso_supp</dc:creator>
      <dc:date>2017-08-30T21:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep/initialize unused variables/constants</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711445#M989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Adam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also experienced the same problem as yours when I developed my project.&lt;/P&gt;&lt;P&gt;In the past when I use KDS, I use KEEP command in ld file to avoid variable being optimized.&lt;/P&gt;&lt;P&gt;MCUXpresso uses manage linker script, if we modify ld file by hand, we will loose the convenience of "manage linker script".&lt;/P&gt;&lt;P&gt;To avoid optimizing global variable, sometimes I wrote dummy code. For example, to avoid g_var being optimized:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; g_var&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;main&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&amp;nbsp; 
&lt;SPAN class="keyword token"&gt;volatile&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; dummy&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp; 
dummy&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;g_var&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:34:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711445#M989</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2017-08-31T09:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep/initialize unused variables/constants</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711446#M990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 13:58:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/how-to-keep-initialize-unused-variables-constants/m-p/711446#M990</guid>
      <dc:creator>adamrakam</dc:creator>
      <dc:date>2017-08-31T13:58:39Z</dc:date>
    </item>
  </channel>
</rss>

