Solved

Using va_arg for variable params in a macro

Posted on 2001-06-19
2
1,208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

695 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