__VAR_ARGS__
-
Hi all. I'm implementing a macro that I need to have take multiple parameters. Let's say I'm implementing a printf macro. (I know. I know. Just run with me for the example. :-D ) #define PRINT(str,...) printf(str,__VAR_ARGS__); Well, obviously, someone could invoke the macro thusly: PRINT("My name is %s and I am %i years old.", szName, iAge); After doing some research, I found __VAR_ARGS__ on gamedev.net. Just one problem: Visual Studio 2008 is not aware for __VAR_ARGS__. Am I misspelling __VAR_ARGS__ or something? What header file is __VAR_ARGS__ (or its correctly spelled version!!) defined? K, thanks!
-
Hi all. I'm implementing a macro that I need to have take multiple parameters. Let's say I'm implementing a printf macro. (I know. I know. Just run with me for the example. :-D ) #define PRINT(str,...) printf(str,__VAR_ARGS__); Well, obviously, someone could invoke the macro thusly: PRINT("My name is %s and I am %i years old.", szName, iAge); After doing some research, I found __VAR_ARGS__ on gamedev.net. Just one problem: Visual Studio 2008 is not aware for __VAR_ARGS__. Am I misspelling __VAR_ARGS__ or something? What header file is __VAR_ARGS__ (or its correctly spelled version!!) defined? K, thanks!
varargs.h by any chance? :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
-
varargs.h by any chance? :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
-
Well, actually, I think I figured it out. It's: __VA_ARGS__ #define PRINT(str,...) printf(str, __VA_ARGS__); //not __VAR_ARGS__ lose the first 'R'.
indeed, however vaargs.h won't cut it. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
-
varargs.h by any chance? :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
-
indeed, however vaargs.h won't cut it. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
hehe. Yeah, I'm still searching for where __VA_ARGS__ *is* defined. I wonder if it's hardcoded into the compiler itself. The C99 standard says it should be supported - whether MS supports it or not I'm truly not at liberty to say until I've tested my still compiling application. (~700K lines).
-
I searched for varargs.h and only my WinARM and cygwin directories have those files. Still searching the tree for __VA_ARGS__.
Hi, my folder C:\Program Files\Microsoft Visual Studio 9.0\VC\include holds a varargs.h file containing definitions for _VA_LIST, va_start(ap), va_arg(ap,t), and more. Yes, __VA_ARGS__ seems not to be there, I think you're right the compiler knows all about that one without any include file. [ADDED] Their documentation[^] knows about it; and you could test it with a much smaller program... [/ADDED] :)
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
modified on Tuesday, December 9, 2008 1:09 PM
-
Hi, my folder C:\Program Files\Microsoft Visual Studio 9.0\VC\include holds a varargs.h file containing definitions for _VA_LIST, va_start(ap), va_arg(ap,t), and more. Yes, __VA_ARGS__ seems not to be there, I think you're right the compiler knows all about that one without any include file. [ADDED] Their documentation[^] knows about it; and you could test it with a much smaller program... [/ADDED] :)
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
modified on Tuesday, December 9, 2008 1:09 PM
-
Hi all. I'm implementing a macro that I need to have take multiple parameters. Let's say I'm implementing a printf macro. (I know. I know. Just run with me for the example. :-D ) #define PRINT(str,...) printf(str,__VAR_ARGS__); Well, obviously, someone could invoke the macro thusly: PRINT("My name is %s and I am %i years old.", szName, iAge); After doing some research, I found __VAR_ARGS__ on gamedev.net. Just one problem: Visual Studio 2008 is not aware for __VAR_ARGS__. Am I misspelling __VAR_ARGS__ or something? What header file is __VAR_ARGS__ (or its correctly spelled version!!) defined? K, thanks!
Looking at this page about variadic macros[^], it should be __VA_ARGS__? You won't find it in any header file, though, because it's something built into the pre-processor.