Solved

Using va_arg for variable params in a macro

Posted on 2001-06-19
2
1,188 Views
Last Modified: 2008-01-16
A colleague wrote me:

"I recently ran across some info about some new C standard allowing a variable number of arguments in a macro via the macro __VA_ARGS__. Does MS C++ allow this in macro's?"

I have never heard of __VA_ARGS__ but found a proposal for it in a document dated 1999, with no followup.  Any info out there?

Is there a way to use the va_arg macro to allow a variable number of parameters in a macro?
0
Comment
Question by:appleby
2 Comments
 
LVL 4

Accepted Solution

by:
IainHere earned 75 total points
ID: 6206832
__VA_ARGS__ is part of the C99 standard.  It is certainly not supported by VC++ 6.0, along with most of the other additions to the language made by C99.

For example, try compiling the following [legal under C99]:

#define DoLogFile(...) fprintf(stderr, __VA_ARGS__)
0
 

Author Comment

by:appleby
ID: 6206860
Ok, thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now