Solved

Using va_arg for variable params in a macro

Posted on 2001-06-19
2
1,193 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lambda for random numbers problem 7 112
VS2015 compilation and missing DLLs 9 147
Find Visual Studio Tools 2 102
Better understanding on C++ Class serialization and formats 9 65
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

786 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