M
Miguel Guedes
Consider the following snippet of code,
#ifdef DEBUG
# define DUMP_DECLARE() public: \
virtual void dump() const
#else
# define DUMP_DECLARE()
#endif // DEBUG
The above macro is used in (some) class declarations like so,
class Bar
{
..
:
..
DUMP_DECLARE();
};
The above compiles fine when DEBUG is defined, however when it is not
defined the compiler spits out warnings complaining about an extra `;',
as given:
.../../src/language.hxx:56:8: warning: extra ';' inside a class [-pedantic]
public:;
^
.../../src/language.hxx:57:17: warning: extra ';' inside a class [-pedantic]
DUMP_DECLARE();
I could easily overcome this warning by making it so that DUMP_DECLARE
never requires a semi-colon at the end:
#define DUMP_DECLARE public: \
virtual void dump() const;
class Bar
{
DUMP_DECLARE()
};
However I thought of asking the comp.lang.c++ experts if there is any
way to overcome this pedantic warning when using the first macro form
that requires the semi-colon. In particular, is there some sort of
declaration similar to (void(0)) that I could employ?
#ifdef DEBUG
# define DUMP_DECLARE() public: \
virtual void dump() const
#else
# define DUMP_DECLARE()
#endif // DEBUG
The above macro is used in (some) class declarations like so,
class Bar
{
..
:
..
DUMP_DECLARE();
};
The above compiles fine when DEBUG is defined, however when it is not
defined the compiler spits out warnings complaining about an extra `;',
as given:
.../../src/language.hxx:56:8: warning: extra ';' inside a class [-pedantic]
public:;
^
.../../src/language.hxx:57:17: warning: extra ';' inside a class [-pedantic]
DUMP_DECLARE();
I could easily overcome this warning by making it so that DUMP_DECLARE
never requires a semi-colon at the end:
#define DUMP_DECLARE public: \
virtual void dump() const;
class Bar
{
DUMP_DECLARE()
};
However I thought of asking the comp.lang.c++ experts if there is any
way to overcome this pedantic warning when using the first macro form
that requires the semi-colon. In particular, is there some sort of
declaration similar to (void(0)) that I could employ?