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 1005847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:21:47+00:00 2026-05-16T08:21:47+00:00

I have thousands of function wrappers which inside actually perform a similar logic like:

  • 0

I have thousands of function wrappers which inside actually perform a similar logic like:

// a, b, ... are variable length parameters of different type

void API_Wrapper(hHandle, a, b, ..)
{
if (hHandle)
   return remote_API(hHandle, a, b, ..);
else
   return API(a, b, ..);
}

I want to use a macro to reuse the if-else logic so I can simply implement the function like this:

void API_Wrapper(hHandle, a, b, ..)
{
    API_CALL(api_name, hHandle, a, b, ..); // API_CALL is a macro
}

I didn’t come up with a good way. (Note: I could solve it via … and __va_args__ but this extension is not supported by the compiler we currently use)

Anyone ever met the same problem and any idea?

  • 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-16T08:21:47+00:00Added an answer on May 16, 2026 at 8:21 am

    Another trick, without variadic macro’s:

    #define API_CALL(hHandle, api_name, arguments) if (hHandle) return remote_##api_name arguments; else return api_name arguments;
    
    void API_Wrapper(int hHandle, int a, double b, char c)
    {
                API_CALL(hHandle, api_name, (a, b, c));
    }
    

    Which becomes:

    void API_Wrapper(int hHandle, int a, double b, char c)
    {
         if (hHandle) return remote_api_name (a, b, c); else return api_name (a, b, c);;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a log file which contains hundreds/thousands of seperate XML messages and need
I have a set containing thousands of addresses. If I can get the longitude
I have a form with thousands of checkboxes, and when one is checked, I
I have a very large codebase (read: thousands of modules) that has code shared
I have several large csv files with thousands of columns that I need to
I have a database table with hundreds of thousands of forum posts, and I
I have some complex stored procedures that may return many thousands of rows, and
I have a folder in NTFS that contains tens of thousands of files. I've
I have an application that creates, and destroys thousands of objects. Is it worth
Here is the problem I have: I have a lot (tens of thousands) of

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.