Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Void

Variable arguments macro?

This topic is 6818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Has anyone been able to implement a macro that takes a variable length of arguments? The closest one I know is something like #define MACRO(x) (printf x) but this requires the call to be made in double parenthesis ie MACRO(("test %d\n",3)); Also, does anyone know of a simple way to check the number of arguments in the va_list correspond to the formatting buffer (without scanning for tokens) Anyone plz?

Share this post


Link to post
Share on other sites
Advertisement
As far as I know, macros with variable arguments can''t be done, unless they are direct aliases for a function that accepts variable arguments itself.

Share this post


Link to post
Share on other sites
SiCrane is right -- You have to have it map to a function that takes a variable number of arguments. I always write these sort of debug logging macros -- easy to compile away in the free build.

The double parenthesis is kind of annoying, I admit.



Notwen
www.xbox.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!