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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:18:17+00:00 2026-05-17T23:18:17+00:00

I have a function mainFunc which needs to call a several times another function

  • 0

I have a function mainFunc which needs to call a several times another function process. A process has a lot of arguments but mainfunc in different calls change only two of them/ Instead of another it passes local variables which are defined and assigned before this calls to process. So I wrote a simple macro which substitutes local variables in calls to process:

#define DO_PROCESS(pred1, est1)     \
do                      \
{                       \
    process(pred1, est1, arg1, arg2, arg3); \
    ++id;                   \ 
    delete est1;                \
} while(0)

arg1, arg2, arg3 are local variables in mainFunc, so I hope my macro will just use them. In mainFunc:

int arg1, arg2, arg3;
arg1 = AssignFirst();
...
Pred* pred;
Est* est;
int estArg;
int predArg;

pred = new Pred(predArg);
DO_PROCESS(pred, new Est(estArg));
delete pred;

pred = new Pred(predArg2);
DO_PROCESS(pred, new Est(estArg2));
delete pred;

pred = new Pred(predArg3);
DO_PROCESS(pred, new Est(estArg3));
delete pred;
....

However I get C2059 and C2143 errors pointing to closing curly brace and semicolon around it respectively in last line of macro.

What’s wrong with it??

  • 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-17T23:18:18+00:00Added an answer on May 17, 2026 at 11:18 pm

    The most likely cause is that there’s extra whitespace after one of the backslashes in the macro definition. Make sure that \ really is the last character on a line.

    Oh, and your code will leak memory, since est1 is evaluated twice in your macro definition – it expands to process(pred1, new Est(...), ...) and then later delete new Est(...), which is not what you meant. Add something like Est *e = est1; before the process call and replace the remaining occurences of est1 in your macro with e to avoid this problem.

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

Sidebar

Related Questions

I have function in Javascript which works fine using prototype. The function is used
I have function getCartItems in cart.js and I want to call that function in
I have function which takes in an parameter of a class called Triple, and
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035
I have a function that gets x(a value) and xs(a list) and removes all
I have a function where I need to do something to a string. I
I have a function that takes, amongst others, a parameter declared as int privateCount
I have a function in a native DLL defined as follows: #include <string> void
I have a function, parseQuery, that parses a SQL query into an abstract representation
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)

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.