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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:08:15+00:00 2026-05-27T06:08:15+00:00

I came across this code recently, which doesn’t look legal to me (but gcc

  • 0

I came across this code recently, which doesn’t look legal to me (but gcc compiles it). I don’t so much mind the construction as want a name for it:

#define MAX(a,b) \
({ \
    typeof(a) _a = (a); \
    typeof(b) _b = (b); \
    (_a > _b) ? (_a) : (_b); \
})

Apparently, the last statement’s value is being returned as the “value” of the expression bounded by the namespace.

Edit: Thanks for the answers guys. Turns out this is an extension to plain C called Statement Expressions.

  • 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-27T06:08:16+00:00Added an answer on May 27, 2026 at 6:08 am

    It is not a namespace, it is a macro which returns maximum of two values.
    \ at the end of the statements is use to append multiple statements and create a multi-line macro.

    The code is not standard C++ but it compiles in gcc because it is supported as an gcc compiler extension.

    Good Read:

    Statement Expressions:
    A compound statement is a sequence of statements enclosed by braces. In GNU C, a compound statement inside parentheses may appear as an expression in what is called a Statement expression.

             .--------------.
             V              |
    >>-(--{----statement--;-+--}--)--------------------------------><
    

    The value of a statement expression is the value of the last simple expression to appear in the entire construct. If the last statement is not an expression, then the construct is of type void and has no value.

    Note: This excerpt is taken from IBM XL C/C++ v7.0 documentation.

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

Sidebar

Related Questions

I recently came across some code like this: parent && parent.removeChild(this); Which takes the
I was look at somebody else's code and came across this piece of code
I recently came across the pandas library for python, which according to this benchmark
I came across this code today and don't really understand it. Please could someone
I recently came across this in some code - basically someone trying to create
I came across this issue when refactoring code recently: The method getList() below has
I recently came across this code example in Mercury: append(X,Y,Z) :- X == [],
i recently came across a part of code which looks like as follows: static
I recently came across this genius bit of code on HTTP POST from PHP,
I recently came across this line in a code - fprintf(logfile, |-IP Version :

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.