Quashing GCC variadic macro warning in C++

Started by
6 comments, last by the_edd 15 years, 7 months ago
Hey folks, I'm wanting to use some C99-style variadic macros (on compilers that support it) for writing tests. GCC (g++) supports them, for example, but always gives me a warning such as:

warning: anonymous variadic macros were introduced in C99
Is there any way to shut it up?
Advertisement
Try compiling with the "--std=c99" setting.
Quote:Original post by implicit
Try compiling with the "--std=c99" setting.

But he is compiling C++ not C?
I suppose you are using the pedantic flag and I would assume there is not a way of turning the warning off. By the way are you using "..." or the named version "foo..." ?
warning: command line option "-std=c99" is valid for C/ObjC but not for C++


:(

I find this particularly annoying because you can use the __extension__ keyword to silence *compiler* warnings related to extensions, but not *preprocessor* warnings.
Quote:Original post by dmail
Quote:Original post by implicit
Try compiling with the "--std=c99" setting.

But he is compiling C++ not C?
I suppose you are using the pedantic flag and I would assume there is not a way of getting of turning the warning off.

I am, and I have the same fear, but I thought I'd check because as I mentioned above, there's __extension__ for the compiler so I was hoping that there's something similar for the preprocessor.

Quote:By the way are you using "..." or the named version "foo..." ?


.../__VA_ARGS__

Quote:Original post by dmail
Quote:Original post by implicit
Try compiling with the "--std=c99" setting.

But he is compiling C++ not C?
I suppose you are using the pedantic flag and I would assume there is not a way of getting of turning the warning off. By the way are you using "..." or the named version "foo..." ?
Oops, I somehow managed to completely miss the fact that we're dealing with C++ despite the thread title and g++ reference.

Anyway, try "-Wno-variadic-macros" instead.
just guessing - i dont actually know what a variadic macro looks like - but maybe something like implicit's suggestion with -XPreprocessor flag ?

Quote: -Xpreprocessor option
Pass option as an option to the preprocessor. You can use this to
supply system-specific preprocessor options which GCC does not know
how to recognize.

If you want to pass an option that takes an argument, you must use
-Xpreprocessor twice, once for the option and once for the argu-
ment.


Quote:Original post by implicit
Quote:Original post by dmail
Quote:Original post by implicit
Try compiling with the "--std=c99" setting.

But he is compiling C++ not C?
I suppose you are using the pedantic flag and I would assume there is not a way of getting of turning the warning off. By the way are you using "..." or the named version "foo..." ?
Oops, I somehow managed to completely miss the fact that we're dealing with C++ despite the thread title and g++ reference.

Anyway, try "-Wno-variadic-macros" instead.


That works nicely on GCC 4, thanks.

For GCC 3, I found you can add this to the file containing the macro definition:

#pragma GCC system_header


A little bit of sick came up in my mouth as I wrote it, but it does the job.

This topic is closed to new replies.

Advertisement