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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:59:22+00:00 2026-06-13T21:59:22+00:00

We have an existing function implementation in our C++ code: void Function(int param) {

  • 0

We have an existing function implementation in our C++ code:

void Function(int param)
{
    printf("In Function\n");
}

int main()
{
    Function(10);
    return 0;
}

I wish to change it to call another function (by help of a macro declaration) which would accept additional params like FILE and LINE (for debugging purpose) and then call the actual function:

#define Function(param) Function_debug(param, __FILE__,  __FUNCTION__,  __LINE__) \
{\
    printf("In Function_debug [%s] [%s] [%d]\n", file, func, line); \
    Function(param);\
}

But the below code:

#include <stdio.h>

#define Function(param) Function_debug(param, __FILE__,  __FUNCTION__,  __LINE__) \
{\
    printf("In Function_debug [%s] [%s] [%d]\n", file, func, line); \
    Function(param);\
}

void Function(int param)
{
    printf("In Function\n");
}

int main()
{
    Function(10);
    return 0;
}

Translates TO:

void Function_debug(int param, "temp.cpp", __FUNCTION__, 9) { printf("In Function_debug [%s] [%s] [%d]\n", file, func, line); Function(int param);}
{
    printf("In Function\n");
}

int main()
{
    Function_debug(10, "temp.cpp", __FUNCTION__, 16) { printf("In Function_debug [%s] [%s] [%d]\n", file, func, line); Function(10);};
    return 0;
}

which gives compilation errors.

Please direct me how to achieve the objective?

  • 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-06-13T21:59:24+00:00Added an answer on June 13, 2026 at 9:59 pm

    Normally you’d do something like this:

    #if DEBUG
    #define FUNCTION(param) Function_debug(param, __FILE__,  __FUNCTION__,  __LINE__)
    #else
    #define FUNCTION(param) Function(param)
    #endif
    
    void Function(int param)
    {
        printf("In Function\n");
    }
    
    void Function_debug(int param, const char * file,  const char * func,  int line)
    {
        printf("In Function_debug [%s] [%s] [%d]\n", file, func, line); \
        Function(param);
    }
    
    int main()
    {
        FUNCTION(10);
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in an existing implementation (can't change the structure much), i'm trying to call a
In Guava, if I have a Collection<T> - is there any existing function in
I have existing code that uses CMNewProfileSearch to find then iterate over the color
I have existing java code and need to create Design Document based on that.
I have existing code with their own makefiles which I want to load into
I have generalized the existing Data.List.partition implementation partition :: (a -> Bool) -> [a]
I have a model dialog. I overrided OnCancel function to stop unexpected exiting by
I have existing Linux shared object file (shared library) which has been stripped. I
I have quick question for you SQL gurus. I have existing tables without primary
I'm working on a project where the client wants to have existing pages dynamically

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.