Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:11:31+00:00 2026-05-24T21:11:31+00:00

On Visual Studio 2005 I have a macro that looks like this (examplified!!): #define

  • 0

On Visual Studio 2005 I have a macro that looks like this (examplified!!):

#define MY_CALL(FUN, ...) \
  if(prepare(x, y)) {     \
    FUN(__VA_ARGS__);     \
  }
/**/

As long as the function takes at least one argument, I’m fine.

When the function takes zero arguments, the preprocessor “helpfully” removes the “trailing comma”, expanding something like this:

if(prepare(x y)) { funct(); }

Great, isn’t it?

How can I fix this macro, so that it’ll work with zero __VA_ARGS__ on Visual C++ (VS 2005)?


Apparently this is a bug in VS2005.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:11:32+00:00Added an answer on May 24, 2026 at 9:11 pm

    Unfortunately, I do not use Visual C++ anymore (and as so cannot verify this works), but can you try this?

    #define MY_CALL(FUN, ...) \
      if(prepare(x, y)) {     \
        int fail[] = {0,}     \
        FUN(__VA_ARGS__);     \
      }
    

    Using gcc 4.2, both {0,} and {0} are allowed in that context, so if the comma gets deleted or not it would not matter. However, I am not certain whether that is generally accepted in the spec, a commonly implemented extension, or something specific to gcc.

    If the {0,} syntax is allowed by Visual C++, then this would hopefully solve your problem (assuming I understand correctly that the most recent comma before __VA_ARGS__ is what is being incorrectly deleted, regardless of where it is appearing in the syntax).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started writing a Macro in Visual Studio 2005 like this: Public Sub
The installer insist that I have Visual Studio 2005 installed. This brings me to
I'm working in Visual Studio 2005 and have added a text file that needs
Visual Studio 2005 C++ Windows XP Pro I have a sample application that I
Microsoft Visual Studio (2005 and 2008) seems to have fun shuffling the Project IDs
I have a Visual Studio 2005 C++ program that runs differently in Release mode
We have several applications written in Visual Studio 2005 that are deployed onto our
Language: Visual C++, MFC Environment: Visual Studio 2005 I have a dialog that requires
I have a visual studio 2005 project with a custom build step that copies
I have an executable build with Visual Studio 2005 using C#. dumpbin reports that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.