<?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: Disabling gcc warnings in CodeWarrior Development Tools</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308670#M785</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;__attribute__ ((unused)) worked, as did (void)(c = 0);&amp;nbsp; What I tried (and thought I used before) was (void) c = 0;, which doesn't work.&amp;nbsp; Following c = 0; with (void) c; generates an error.&amp;nbsp; I didn't try the volatiles.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll take a look at the documentation.&amp;nbsp; Those pdf's are buried deep in the tree.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Jorge and Matthew!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2014 19:00:35 GMT</pubDate>
    <dc:creator>d_</dc:creator>
    <dc:date>2014-06-10T19:00:35Z</dc:date>
    <item>
      <title>Disabling gcc warnings</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308666#M781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to the CodeWarrior environment.&amp;nbsp; I'm used to making sure there are not only no errors (duh!) but no warnings in my compiles.&amp;nbsp; Some warnings are generated in SOUP and I don't want to modify the SOUP, and some warnings are justifiable (which in some medical environments must be justified).&amp;nbsp; What I have done in the past is to disable warnings globally when they can have no affect on the code, or disable warnings for a single line of code (or a file, but not as good).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using an E02 processor and am stuck with the gcc compiler.&amp;nbsp; I've searched the archives here and there are plenty of hits for disabling warnings, but after digging through them none seem to apply to the gcc compiler.&amp;nbsp; I'm also used to getting warning numbers, but this compiler only generates messages.&amp;nbsp; For example,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;format '%d' expects argument of type 'int', but argument 2 has type 'uint32_t' [-Wformat]&lt;/P&gt;&lt;P&gt;variable 'c' set but not used [-Wunused-but-set-variable]&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first one I can take care of by just commenting out the line of code, only used for debug.&amp;nbsp; But it would be nice to disable the warning for just this line.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second one is a problem because the hardware requires a register read to set conditions in the peripheral, even though the data isn't used.&amp;nbsp; In other compilers, I've been able to eliminate this kind of warning by casting the variable as (void) in the statement that uses it.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 00:36:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308666#M781</guid>
      <dc:creator>d_</dc:creator>
      <dc:date>2014-05-30T00:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Disabling gcc warnings</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308667#M782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Dave:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way to bypass that specific warning is by adding an attribute to the variable declaration. Here an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14019944802168811" jivemacro_uid="_14019944802168811" modifiedtitle="true"&gt;
&lt;P&gt;int main(void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __attribute__ ((unused)) int counter = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your reference there are some documents (kind of hidden in there actually) about GCC compiler and linker in your CodeWarrior installation folder:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\CW MCU v10.6\Cross_Tools\arm-none-eabi-gcc-4_7_3\share\doc\gcc-arm-none-eabi\pdf&amp;nbsp; -&amp;gt; &lt;STRONG&gt;ld.pdf&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\CW MCU v10.6\Cross_Tools\arm-none-eabi-gcc-4_7_3\share\doc\gcc-arm-none-eabi\pdf\gcc&amp;nbsp; -&amp;gt; &lt;STRONG&gt;gcc.pdf&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!,&lt;BR /&gt;Jorge Gonzalez&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, 05 Jun 2014 19:06:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308667#M782</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2014-06-05T19:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Disabling gcc warnings</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308668#M783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jorge.  I'll try that and look for the document.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 19:25:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308668#M783</guid>
      <dc:creator>d_</dc:creator>
      <dc:date>2014-06-05T19:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Disabling gcc warnings</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308669#M784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Performing a no-effect access to the variable, for example by casting it to void, works fine to suppress the "set but not used" warning in gcc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, this gives warning: variable 'c' set but not used [-Wunused-but-set-variable]&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14020987958154754" jivemacro_uid="_14020987958154754"&gt;
&lt;P&gt;char c;&lt;/P&gt;
&lt;P&gt;c = 0;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whereas this gives no warnings:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_140209886970744 jive_macro_code" jivemacro_uid="_140209886970744" modifiedtitle="true"&gt;
&lt;P&gt;char c;&lt;/P&gt;
&lt;P&gt;c = 0;&lt;/P&gt;
&lt;P&gt;(void)c;&amp;nbsp;&amp;nbsp;&amp;nbsp; // suppress warning&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also do it all in one go, although it is a little less clear:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14020990074335744" jivemacro_uid="_14020990074335744"&gt;
&lt;P&gt;char c;&lt;/P&gt;
&lt;P&gt;(void)(c = 0);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But perhaps you can avoid the problem altogether. You say:&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;the hardware requires a register read to set conditions in the peripheral, even though the data isn't used&lt;/BLOCKQUOTE&gt;&lt;P&gt;so it sounds like you are actually doing something like this:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14021001506538512" jivemacro_uid="_14021001506538512" modifiedtitle="true"&gt;
&lt;P&gt;char c;&lt;/P&gt;
&lt;P&gt;volatile char *p = REGISTER_ADDRESS;&lt;/P&gt;
&lt;P&gt;c = *p;&amp;nbsp; // read register to clear hardware&lt;/P&gt;
&lt;P&gt;(void)c; // suppress warning&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when you could probably just do this:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1402100161035431" jivemacro_uid="_1402100161035431" modifiedtitle="true"&gt;
&lt;P&gt;volatile char *p = REGISTER_ADDRESS;&lt;/P&gt;
&lt;P&gt;*p;&amp;nbsp; // read register to clear hardware&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that you need the volatile type qualifier to prevent the access being optimised away. You will get a "statement has no effect" warning without it (unless you suppress that with a cast to void also).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2014 00:23:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308669#M784</guid>
      <dc:creator>matthewkendall</dc:creator>
      <dc:date>2014-06-07T00:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Disabling gcc warnings</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308670#M785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;__attribute__ ((unused)) worked, as did (void)(c = 0);&amp;nbsp; What I tried (and thought I used before) was (void) c = 0;, which doesn't work.&amp;nbsp; Following c = 0; with (void) c; generates an error.&amp;nbsp; I didn't try the volatiles.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll take a look at the documentation.&amp;nbsp; Those pdf's are buried deep in the tree.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Jorge and Matthew!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 19:00:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Disabling-gcc-warnings/m-p/308670#M785</guid>
      <dc:creator>d_</dc:creator>
      <dc:date>2014-06-10T19:00:35Z</dc:date>
    </item>
  </channel>
</rss>

