Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using va_arg for variable params in a macro

Posted on 2001-06-19
2
Medium Priority
?
1,221 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 300 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

810 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