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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:08:56+00:00 2026-05-30T13:08:56+00:00

let me explain my confusion with sample code this is our macro #define rsAssert(v)

  • 0

let me explain my confusion with sample code

this is our macro

#define rsAssert(v)   if(!(v)) printf("rsAssert failed: %s, in %s at %i" #v, __FILE__, __LINE__); 

case 1:

int main(void)
{
  rsAssert(0);
  return 0;
}

this case compiles succesfully

case 2

int main(void)
{
  rsAssert(0)  // note here ;  is not present
  return 0;
}

this also compiles succsfully
Question 1:

it means whether you write rsAssert(0) or rsAssert(0); no difference between them?


then

case 3

int main()
{
  if(1)
    rsAssert(0);
  else 
    printf("mr.32");
  return 0;
}

here rsassert(0); is not going to compile [see http://ideone.com/7dFv1%5D but without ; rsasser(0) works fine [see http://ideone.com/8fehl%5D..

I am not getting what’s going on with macro expansion here…

  • 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-30T13:08:58+00:00Added an answer on May 30, 2026 at 1:08 pm

    The reason it is not working in case 3 is because this is what is actually getting compiled:

    int main()
    {
    if(1)
      if(!(v)) printf("rsAssert failed: %s, in %s at %i", #v, __FILE__, __LINE__);;
    else 
      printf("mr.32");
    return 0;
    }
    

    Note the extra semicolon at the end of the first printf from the macro.

    Normally, with an if statement, it’s followed by a single statement, or a block with { }.

    But because of the extra ;, you have this:

    if (...) 
        printf(...); ;
    else
        printf(...);
    return 0;
    

    That extra semicolon is an empty statement, but is still a statement nonetheless.

    You should remove the ; from the macro. Then things would make more sense.

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

Sidebar

Related Questions

Let me explain: this is path to this folder: > www.my_site.com/images And images are
Sorry for the confusing title. Let me explain via code: #include <string> #include <boost\function.hpp>
So let me explain my problem a little better now (please reopen this question).
Let's see if I can explain this properly. I am (unfortunately) using Access. I
Let me explain.. I want to do this: a = somedir.somefile b = someclass
Let me explain this a bit. Imagine I have a table like this: id
I had a confusion let me explain it in brief. I have a form
Title might be a bit confusing, so let me explain. I have a website
Sorry if the question title is confusing. Let me explain further. I am building
the title might be a little bit confusing, let me explain, ;) I have

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.