delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/11/19:55:14

Date: Sat, 11 Oct 1997 16:52:40 -0700 (PDT)
Message-Id: <199710112352.QAA25391@adit.ap.net>
Mime-Version: 1.0
To: nuser AT rsuzi DOT pgu DOT karelia DOT ru, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Warning control. Is there more convenient way?

At 09:58  10/11/1997 +0300, Roman Suzi wrote:
>Hi, all!
>
>I have an annoying problem with C and C++ (DJGPP).
>
>The question is: how to control 'unused argument/variable'
>warning so, that I will receive a warning only
>when it is really  wanted?
>(The problem is not just that of switching
>all warnings manually and leaving unswitched
>a few of them)
>
>In some functions I have comletely justified unused variables:
>they are just pointing the type of template, or
>they are elements in arrays of functions, but
>some parameters are unused.
>But sometimes the warning become warning: I dont want
>just switch the flag off.
>
>
>
>What can I add to suppress them in GCC, so that
> - I shall not receive another kind of warning;
> - the effectiveness of the code will remain the
>same (no additional commands will be inserted for dummy
>usage of the variables) ?
So you want to suppress the warning just in certain places? If you want to
suppress completely, use -Wno-unused. Otherwise, you can place something like:

int unused_variable;

(void)unused_variable;

The compiler is smart enough not to generate any code for it. Look at the
assembly and see!

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019