This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to turn off a warning for one line of code.
- To: scherrey at proteus-tech dot com
- Subject: Re: How to turn off a warning for one line of code.
- From: Carlo Wood <carlo at runaway dot xs4all dot nl>
- Date: Sat, 10 Oct 1998 18:43:39 +0200 (CEST)
- Cc: egcs at cygnus dot com (egcs at cygnus dot com)
| --- debug.hpp
| #ifdef DEBUG
| #define PDBUG cout __FILE__ << ":" __LINE__ <<
| // Its actually a lot more complicated than this but you get the
| idea.
| #else
| #define PDBUG false && cout
| // used to be able to #define PDBUG /##/ but egcs won't let me. :-(
| #endif // DEBUG
|
| --- test.cpp
| #include "debug.hpp"
| PDBUG << "My error message..." << endl;
|
| Now this code generates warnings that say:
| warning: statement with no effect
| every time I used PDBUG with debugging turned off. That's a LOT of
| places!
Maybe an idea, I use this:
Debug( "My error message..." << endl; )
Where either
#define Debug(x)
or
#define Debug(x) cerr << x
...
Now I think of it, why don't you use
#define PDBUG if(0)cout
That doesn't give a warning. Of course you'll need optimisation
to get rid of the test for 0.
--
Carlo Wood <carlo@runaway.xs4all.nl>