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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:42:48+00:00 2026-06-09T16:42:48+00:00

Can I define a macro like: #define ERROR_REPORT(LEVEL,SUB_LEVEL printf( Compiler complain this line expecting

  • 0

Can I define a macro like:

#define ERROR_REPORT(LEVEL,SUB_LEVEL printf(

Compiler complain this line expecting a ;. Is there a way to escape the “(“?

This is intended to replace a function:

  ERROR_REPORT(LEVEL,SUB_LEVEL
          "error, there is an error %d\n",
           error_id);

with a C built-in function

  printf("error, there is an error %d\n",
         error_id);

EDIT: I just want to replace one “(“, not include “)”. The reason why I ask this is that there are already some codes as posted in question, so I just want to replace one line like ERROR_REPROT(… with printf( .

  • 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-09T16:42:48+00:00Added an answer on June 9, 2026 at 4:42 pm

    I suggest you use variadic macros:

    #define ERROR_REPORT(LEVEL, SUB_LEVEL, ...) \
        printf(__VA_ARGS__)
    

    While you can put whatever you want as the replacement for a macro, you define it wrong:

    #define ERROR_REPORT(LEVEL,SUB_LEVEL   printf(
    /*      Error with missing `)` here ^ */
    

    The preprocessor needs the closing parenthesis, or it will cause errors in the preprocessing phase.

    Also when you are using this macro you can’t do as you do:

    ERROR_REPORT(LEVEL,SUB_LEVEL
          "error, there is an error %d\n",
           error_id);
    

    The preprocessor will throw an error here too as there is no comma between the SUB_LEVEL argument and the string.

    So the answer to the question if you can replace a single left parenthesis is simply no, you can’t.

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

Sidebar

Related Questions

Can you do something like this with a macro in C ? #define SUPERMACRO(X,Y)
When using C preprocessor one can stringify macro argument like this: #define TO_STRING(x) a
I can define default value in domain by this way : class ProcessingPriority {
I have macro like this: #define error_exit(format, ...) \ error_at_line(EXIT_FAILURE, 0, __FILE__, __LINE__, format,
I want a macro that I can use like this: CREATE_URL(@{SOME-TOKEN}/some/url/path); The macro should
I have a macro that looks like this: #define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR)
We have a macro for error-checking that goes like this: #define CheckCondition( x )
I want to have a macro dbtest that can be used like this: (dbtest
For example, never define a macro like this: #define DANGER 60 + 2 This
Does anyone know if and/or how you can define macro definitions in a gSoap

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.