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

  • Home
  • SEARCH
  • 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 1030595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:43:32+00:00 2026-05-16T12:43:32+00:00

#define boo(fmt, …) SomethingToDo(fmt, __VA_ARGS__) void foo(PCSTR fmt, …) { // some other codes

  • 0
#define boo(fmt, ...)   SomethingToDo(fmt, __VA_ARGS__)
void foo(PCSTR fmt, ...)
{
    // some other codes
    if(condition1)
    {
        va_list marker;
        va_start(maker, fmt);
        // Do something.
        va_end(marker);
    }

    if(somecondition)
        boo(fmt, /* I want to put the foo's va_arguments here */);
}

There were many codes which call foo function in my project.
I made a new macro boo today. And I want to call the macro in foo function.

How can I do this?

Edit:
Of course, we can solve this problem to call some functions(Not macro) like StringCbVPrintf.
But I’m finding a way to call a macro.

  • 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-16T12:43:33+00:00Added an answer on May 16, 2026 at 12:43 pm

    An answer that was deemed unhelpful

    The question was not properly explained. This answer didn’t answer the question that the questioner had in mind, but did answer the question that seemed to be asked. There was a gap between intention and reality.

    #define boo(fmt, ...) SomethingToDo(fmt, __VA_ARGS__) // semi-colon removed!
    void foo(PCSTR fmt, ...)
    {
        // some other codes
    
        // I want to call boo with VarArgs.
        if (somecondition)
            boo(fmt, arg1, arg2);
        if (anothercondition)
            boo("%x %y %z", e1, e2, e3);
        if (yetanothercondition)
            boo("&T99 P37 T22 9%X  ZZQ", x1, y2, z3, a4, b9, c7, q99);
    }
    

    All facetiousness apart, you call a function or macro with the arguments needed to get your job done. Since you don’t specify what the format should be formatted like, I’ve made up format strings to suit myself – they probably aren’t very usable, but who knows.

    Anyway, the key point is that you can call boo() the macro with different lists of arguments, and those arguments will be conveyed to SomethingToDo().


    An answer that was deemed more helpful

    Given the clarification in the comment, then:

    #define boo(fmt, ...)   SomethingToDo(fmt, __VA_ARGS__)
    void foo(PCSTR fmt, ...)
    {
        va_list args;
    
        // I want to call boo with VarArgs.
        if (somecondition)
        {
            va_start(args, fmt);
            boo(fmt, args);
            va_end(args);
        }
    }
    

    However, for that to work, the underlying function needs to know how to handle a va_list. That means you normally end up with the following code with a structure similar to the following:

    void vSomethingToDo(const char *fmt, va_list args)
    {
        ...code using vfprintf() or whatever...
    }
    
    void SomethingToDo(const char *fmt, ...)
    {
        va_list args;
        va_start(args, fmt);
        vSomethingToDo(fmt, args);
        va_end(args);
    }
    
    #define vboo(fmt, args) vSomethingToDo(fmt, args)
    #define boo(fmt, ...)    SomethingToDo(fmt, __VA_ARGS__)
    
    void foo(PCSTR fmt, ...)
    {
        ...other code...
        if (somecondition)
        {
            va_list args;
            va_start(args, fmt);
            vboo(fmt, args);
            va_end(args);
        }
    }
    

    This is a ‘standard pattern’ for code that uses variable arguments. You can see it in standard C with: printf() and vprintf(); snprintf() and vsnprintf(); fprintf() and vfprintf(); and so on. One version of the function has an ellipsis in the argument list; the other version is prefixed with the letter ‘v’ and takes a ‘va_list’ in place of the ellipsis. The ellipsis code is standardized to four or five lines – more or less as shown; it creates and initializes va_list with va_start, calls the v-function, and returns the result after doing va_end.

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

Sidebar

Related Questions

#define BUF_SIZE 10 char *html = foo:baa\r\nxxx:yyyy:\r\nLocation:........................................\r\Connection:close\r\n\r\n; char *p = (char*)html, *buf, *pbuf, *tbuf;
/* #define FOO */ #ifdef FOO #define BAR pirate #else #define BAR ninja #endif
#define UPUT_SET_CHECK_POINT1(appType, tag, argNum1, v1, ...) \ if(NUMARGS(##__VA_ARGS__) == 0) \ UPUT_SET_CHECK_POINTx(1, appType, tag,
define(foo,0000) foo 0000 undefine('foo') foo 0000 thanks. jcyang.
I want something like this: class Foo<T>{...} class Boo<T>{ Queue<T> stuff = new Queue<T>();
Why doesn't this work: var foo = function() { ... }; var boo =
In PHP if I define a constant like this: define('FOO', true); if(FOO) do_something(); The
#define SWAP_PTRS(a, b) do { void *t = (a); (a) = (b); (b) =
define('VAR_1', 'Some info 01'); define('VAR_2', 'Some info 02'); define('VAR_3', 'Some info 03'); define('VAR_4', 'Some
I've defined the following route: routes.MapRoute( null, foo/{id}/{title}, new { controller = Boo, action

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.