Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

For debugbuilds, I usually use Clang, as it formats warnings and errors better, and makes it a little easier to track them down, and fix them.

But recently after adding a Macro with variadic arguments, Clang told me the following (from a dummy project):

main.cpp:5:20: warning: named variadic macros are a GNU extension [-Wvariadic-macros]
#define stuff3(args...)  stuff_i(args)

I know that macroname(args...) compiles fine in a wide range of compilers, including Visualstudio, Sunstudio, and of course GCC. But just to make sure that clang is right, I tried two other ways of expanding the variadic arguments:

Number 1:

#define stuff1(...)  stuff_i(...)

Number 2:

#define stuff2(...)  stuff_i(__VA_ARGS__)

On both I receive this message:

main.cpp:3:16: warning: variadic macros were introduced in C99 [-Wvariadic-macros]

... Which makes me wonder if Variadic macros are actually part of the standard of C++ (and of course I know that the Preprocessor is interpreted independently)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
794 views
Welcome To Ask or Share your Answers For Others

1 Answer

Quote Wikipedia:

Variable-argument macros were introduced in 1999 in the ISO/IEC 9899:1999 (C99) revision of the C language standard, and in 2011 in ISO/IEC 14882:2011 (C++11) revision of the C++ language standard.

So it's standard from C99 and C++11 onwards, but a GNU extension in C++03.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...