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

From: firewind <firewind AT metroid DOT dyn DOT ml DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Warning control. Is there more convenient way?
Date: 11 Oct 1997 21:17:46 GMT
Organization: Netcom
Lines: 50
Distribution: world
Message-ID: <61oqdq$dcn@dfw-ixnews6.ix.netcom.com>
References: <AD7EoFq8hO AT rsuzi DOT pgu DOT karelia DOT ru>
NNTP-Posting-Host: elp-tx2-10.ix.netcom.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Roman Suzi <nuser AT rsuzi DOT pgu DOT karelia DOT ru> 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?

[snip]

> 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) ?

> I think the author of DJGPP can easily include
> along INCLUDE warning checkboxes the EXCLUDE
> warning ones: so it will be much easier to
> check just 'Wall' and a few of unwanted warnings.

Surely you mean the author of RHIDE? In the warning checkbox listings, those
warning that start with '-Wno-' turn -off- certain warnings. So, to use
'-Wall' but not get ANY 'unused variable' warnings (to turn it off for
certain variables only, see below) you would check '-Wall' and
'-Wno-unused'

> Or are there any #pragma s  to do the trick?

gcc is unfond of #pragma, apparently; instead it uses the (incredibly less
portable) __attribute__((unused)) in the declaration of a variable to
disable the warning. For more information, see:

info gcc "C Extensions" "Variable Attributes"

[snip]

-- 
[- 				 firewind	                            -]
[-   email: firewind AT metroid DOT dyn DOT ml DOT org (home), firewind AT aurdev DOT com (work)  -]
[- 	    "You're just jealous because the voices talk to -me-."          -]
[-                   Have a good day, and enjoy your C.		            -]

- Raw text -


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