[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pedantic Variadic Macro Warning

From: news4mr
Subject: Pedantic Variadic Macro Warning
Date: 20 Mar 2006 13:05:20 -0800
User-agent: G2/0.2


I'm using a construct like

#define LOG(logName, level, fmt, ...) \
  do { \
    if ((level) >= MAX_LOGLEVEL) \
      MyUtils::log(logName, level, fmt, __VA_ARGS__); \
  } while(0)

This works fine, but - since this code is contained in a header file
and I am using the -pedantic switch - it emits a lot of warnings saying
that anonymous variadic macros are a C99 feature, which is of course

Now I have the following problems to switch these warnings off:
- I can't switch to std C99 since I'm using C++.
- I want to keep my -pedantic switch. It would be ok for me to switch
it off for a single source file, but since this code is in a .h, I'd
have to switch it off in the whole project.
- I'm using a V3.2 g++ and I would not like to switch to a newer g++,
since I'm cross-compiling and everything works fine. (I know that more
recent g++ versions have a switch called -Wno-variadic-macros.)

Is there any solution to get rid of these warnings with the three
constraints above? I.e. is there any way to switch off the pedantic
checks for just the variadic macro lines above? Is there a pragma I
could use? Or how should I do? (I played around with __extension__ but
I guess that does not work for macros, right?)

Thanks for your time!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]