user22924: When I first started with the Arduino environment I noticed that it had File | Preferences | Compiler Warnings set to None, so I set it to All - and there were many, many warnings in the supplied libraries! So I quickly set it to None again - until later.
Well, "later" is now, and I started going through the warnings to fix the code to quiet the compiler.
Note that I don't want to disable any warnings - I want to placate the compiler at each spot so that it says to itself "No problem here!"

If the compiler complains of an unused variable, I comment out the variable;
If it complains of a signed/unsigned comparison, I change the type;
If it complains of an unused parameter in a function, I...

...hmmm. If this was C++, I'd simply comment out the parameter name, leaving the type naked:
void Fn(int /*param*/) {
} // Fn(param)


Arduino reports:
error: parameter name omitted

But that isn't legal in C. With some compilers you can use the __unused attribute:
void Fn(int __unused param) {
} // Fn(param)


Arduino reports:
error: expected ';', ',' or ')' before 'param'
    It's interpreting __unused as the actual parameter name

or if they're fussy:
void Fn(int __attribute__((unused)) param) {
} // Fn(param)


Arduino reports:
warning: unused parameter 'param' [-Wunused-parameter]
    That's not the correct __attribute__, obviously

So none of the above work in the Arduino environment. Suggestions?

I've been programming in C and C++ for over twenty years, and I know that the #1 thing you should always do is ask the compiler to tell you about everything it notices. You need a warning-free compile at all times! Otherwise, you spend hours or days trying to find a bug - only to discover that the compiler has been warning you about it all along...

user23965: Within the body of a function you can do this to suppress a warning:
void do_something(int value) {
  (void) (value);
  . . .
}

You can use a macro to do the same thing, for better clarity:
#define UNUSED(v) (void) (v)

void do_something(int value) {
  UNUSED(value);
  . . .
}

This can be helpful in situations where you have conditional compilation:
void do_something(int value) {
  #ifndef USES_PARAM
    UNUSED(value);
  #else
    other_stuff(value);
  #endif
  . . .
}


user22924: Well, I typed all that question up for posting, then tried one last thing. It worked!
void Fn(__attribute__((unused)) int param) {
} // Fn(param)

So, rather than let a good question go to waste: here's the answer!
Now all we need to do is get the maintainers of all the libraries to put these in... and fix the other warnings...

22924: <p>When I first started with the Arduino environment I noticed that it had <code>File | Preferences | Compiler Warnings</code> set to <code>None</code>, so I set it to <code>All</code> - and there were many, many warnings in the supplied libraries! So I quickly set it to <code>None</code> again - until later.</p>

<p>Well, "later" is now, and I started going through the warnings to fix the code to quiet the compiler.</p>

<p><strong>Note that I don't want to <em>disable</em> any warnings</strong> - I want to placate the compiler at each spot so that it says to itself "No problem here!"</p>

<ul>
<li>If the compiler complains of an unused variable, I comment out the variable;</li>
<li>If it complains of a signed/unsigned comparison, I change the type;</li>
<li>If it complains of an unused parameter in a function, I...</li>
</ul>

<p>...hmmm. If this was C++, I'd simply comment out the parameter name, leaving the type naked:</p>

<pre><code>void Fn(int /*param*/) {
} // Fn(param)
</code></pre>

<blockquote>
  <p>Arduino reports:<br>
    <code>error: parameter name omitted</code></p>
</blockquote>

<p>But that isn't legal in C. With some compilers you can use the <code>__unused</code> attribute:</p>

<pre><code>void Fn(int __unused param) {
} // Fn(param)
</code></pre>

<blockquote>
  <p>Arduino reports:<br>
    <code>error: expected ';', ',' or ')' before 'param'</code><br>
    It's interpreting <code>__unused</code> as the actual parameter name</p>
</blockquote>

<p>or if they're fussy:</p>

<pre><code>void Fn(int __attribute__((unused)) param) {
} // Fn(param)
</code></pre>

<blockquote>
  <p>Arduino reports:<br>
    <code>warning: unused parameter 'param' [-Wunused-parameter]</code><br>
    That's not the correct <code>__attribute__</code>, obviously</p>
</blockquote>

<p>So none of the above work in the Arduino environment. Suggestions?</p>

<hr>

<p>I've been programming in C and C++ for over twenty years, and I know that the #1 thing you should always do is ask the compiler to tell you about <strong>everything</strong> it notices. You need a warning-free compile at all times! Otherwise, you spend hours or <em>days</em> trying to find a bug - only to discover that the compiler has been warning you about it all along...</p>
 23965: <p>Within the body of a function you can do this to suppress a warning:</p>

<pre><code>void do_something(int value) {
  (void) (value);
  . . .
}
</code></pre>

<p>You can use a macro to do the same thing, for better clarity:</p>

<pre><code>#define UNUSED(v) (void) (v)

void do_something(int value) {
  UNUSED(value);
  . . .
}
</code></pre>

<p>This can be helpful in situations where you have conditional compilation:</p>

<pre><code>void do_something(int value) {
  #ifndef USES_PARAM
    UNUSED(value);
  #else
    other_stuff(value);
  #endif
  . . .
}
</code></pre>
 22924: <p>Well, I typed all that question up for posting, then tried one last thing. It worked!</p>

<pre><code>void Fn(__attribute__((unused)) int param) {
} // Fn(param)
</code></pre>

<p>So, rather than let a good question go to waste: here's the answer!</p>

<p>Now all we need to do is get the maintainers of all the libraries to put these in... and fix the other warnings...</p>
