Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: best way to suppress "unused" warning?

Reply
Thread Tools

Re: best way to suppress "unused" warning?

 
 
Antoninus Twink
Guest
Posts: n/a
 
      04-25-2008
On 25 Apr 2008 at 1:24, Richard Heathfield wrote:
> Lots of people use (void)data for this, and it's just as good a way as
> any of those you mention


Obfuscating your code to pacify your compiler or lint smacks to me of
letting the tail wag the dog.

 
Reply With Quote
 
 
 
 
Joachim Schmitz
Guest
Posts: n/a
 
      04-25-2008
Antoninus Twink wrote:
> On 25 Apr 2008 at 1:24, Richard Heathfield wrote:
>> Lots of people use (void)data for this, and it's just as good a way
>> as any of those you mention

>
> Obfuscating your code to pacify your compiler or lint smacks to me of
> letting the tail wag the dog.

In real life there may be coding standards that demand for this.

At one company I used to work for it was mandatory to use "-Wall -Werror",
or something eqivalent and all new code and on all older code once it got
touched.

It was a pain in the proverbian, but lead to much better code and lots of
yet unexplained faults mysteriously disappaered...

Bye, Jojo


 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      04-25-2008
In article <(E-Mail Removed)>,
Antoninus Twink <(E-Mail Removed)> wrote:

>> Lots of people use (void)data for this, and it's just as good a way as
>> any of those you mention


>Obfuscating your code to pacify your compiler or lint smacks to me of
>letting the tail wag the dog.


It's a difficult balance to strike. I have at least once missed an
important warning because it was surrounded by unimportant ones that
I was expecting.

-- Richard



--
:wq
 
Reply With Quote
 
Peter Nilsson
Guest
Posts: n/a
 
      04-29-2008
Joachim Schmitz wrote:
> Antoninus Twink wrote:
> > Richard Heathfield wrote:
> > > Lots of people use (void)data for this, and it's just as good
> > > a way as any of those you mention

> >
> > Obfuscating your code to pacify your compiler or lint smacks
> > to me of letting the tail wag the dog.

>
> In real life there may be coding standards that demand for this.


Of course, tail wagging the dog is standard policy in many
avenues of life. That doesn't mean it's sensible.

> At one company I used to work for it was mandatory to use
> "-Wall -Werror", or something eqivalent and all new code and
> on all older code once it got touched.


So if the compiler ever get's upgraded, you may have to 'correct'
thousands of lines of perfectly correct code because the compiler
writers decided to add another warning? Brilliant.

Did you have to rewrite third party library sources as well?

> It was a pain in the proverbian, but lead to much better code


Warning free is not a measure of 'better'. But I'm in a minority
on that.

> and lots of yet unexplained faults mysteriously disappaered...


I'm sure it also lead to the appearance (albeit rare) of
mysterious faults that went undiscovered for some time until a
critical moment precisely because all the programmers have
been conditioned to write code that eludes diagnostics and
static analysis.

Ever heard the term superbugs.

--
Peter
 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      04-29-2008
"Peter Nilsson" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Joachim Schmitz wrote:
>> Antoninus Twink wrote:
>> > Richard Heathfield wrote:
>> > > Lots of people use (void)data for this, and it's just as good
>> > > a way as any of those you mention
>> >
>> > Obfuscating your code to pacify your compiler or lint smacks
>> > to me of letting the tail wag the dog.

>>
>> In real life there may be coding standards that demand for this.

>
> Of course, tail wagging the dog is standard policy in many
> avenues of life. That doesn't mean it's sensible.
>
>> At one company I used to work for it was mandatory to use
>> "-Wall -Werror", or something eqivalent and all new code and
>> on all older code once it got touched.

>
> So if the compiler ever get's upgraded, you may have to 'correct'
> thousands of lines of perfectly correct code because the compiler
> writers decided to add another warning? Brilliant.

The vast majority was stuff like comment inside comment, steming from the
function headers like this:

/***********
/*
/* some text describing the function
*/

Once they've been fixed, the real warnings became visible.
Statement with no effect (e.g. from ; after while())
conversion of <type> to <type> without a case (and no the fix was not to add
the cast)
implicit declaration of <function>
unused variable

etc.

Newer compiler versions didn't create many new warnings, so that wasn't much
of an issue,
but porting to a different platform (and compiler) then produced a new and
extensive set of warnings, the majority usefull and correct ones.

> Did you have to rewrite third party library sources as well?

There were none, fortunatly.

>> It was a pain in the proverbian, but lead to much better code

>
> Warning free is not a measure of 'better'. But I'm in a minority
> on that.
>
>> and lots of yet unexplained faults mysteriously disappaered...

One example was lots of warnigs about unused variables. We removed these and
the code didn't crash anymore. Later we learned that that particular
compiler's optimizer had a problem with unused vairables, resulting in bad
code.
OK, in this case a compiler upgrade would have fixed it too, but at that
time we a) didn't know and b) the fixed compiler wasn't available.

> I'm sure it also lead to the appearance (albeit rare) of
> mysterious faults that went undiscovered for some time until a
> critical moment precisely because all the programmers have
> been conditioned to write code that eludes diagnostics and
> static analysis.

I'm not aware of any

Bye, Jojo


 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      04-29-2008

"Peter Nilsson" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Joachim Schmitz wrote:

<snip>
>> (removing the warnings) was a pain in the proverbian, but lead to much
>> better code

>
> Warning free is not a measure of 'better'. But I'm in a minority
> on that.

It was not (only) better because of the lack of warnings, but (mainly) due
to the numbers of bugs we spotted and removed in the due course of
investigating and eliminating the warnings.

Bye, Jojo


 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      04-29-2008
Joachim Schmitz wrote:
> Antoninus Twink wrote:
>> On 25 Apr 2008 at 1:24, Richard Heathfield wrote:
>>> Lots of people use (void)data for this, and it's just as good a way
>>> as any of those you mention

>> Obfuscating your code to pacify your compiler or lint smacks to me of
>> letting the tail wag the dog.

> In real life there may be coding standards that demand for this.
>

Adding unnamed parameters would fix this case and break nothing. But I
guess there little chance of such a simple change making its way into
the standard.

--
Ian Collins.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: best way to suppress "unused" warning? fred.l.kleinschmidt@boeing.com C Programming 0 04-25-2008 04:12 PM
Way to suppress WebResource.axd sent to client? Evan ASP .Net 0 08-16-2006 01:19 PM
How do you disable or suppress the '?' interactive help function John Chajecki Cisco 2 12-17-2005 03:32 PM
How to suppress headers when forwarding with TB David G. Imber Firefox 3 10-17-2005 08:51 PM
Suppress more/pause during running config Marv Cisco 3 06-20-2005 05:33 PM



Advertisments