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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:45:32+00:00 2026-05-14T20:45:32+00:00

In the Android open-source qemu code I ran across this line of code: machine->max_cpus

  • 0

In the Android open-source qemu code I ran across this line of code:

machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */

Is this just a confusing way of saying:

if (machine->max_cpus) {
   ; //do nothing
} else {
 machine->max_cpus = 1;
}

If so, wouldn’t it be clearer as:

if (machine->max_cpus == 0) machine->max_cpus = 1;

Interestingly, this compiles and works fine with gcc, but doesn’t compile on http://www.comeaucomputing.com/tryitout/ .

  • 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-14T20:45:32+00:00Added an answer on May 14, 2026 at 8:45 pm

    This is permitted in GNU as an obscure extension to C

    5.7 Conditionals with Omitted Operands

    The middle operand in a conditional
    expression may be omitted. Then if the
    first operand is nonzero, its value is
    the value of the conditional
    expression.

    Therefore, the expression

     x ? : y
    

    has the value of x if that is nonzero;
    otherwise, the value of y.

    This example is perfectly equivalent
    to

     x ? x : y
    

    In this simple case, the ability to
    omit the middle operand is not
    especially useful. When it becomes
    useful is when the first operand does,
    or may (if it is a macro argument),
    contain a side effect. Then repeating
    the operand in the middle would
    perform the side effect twice.
    Omitting the middle operand uses the
    value already computed without the
    undesirable effects of recomputing it.

    As you can probably guess, avoiding this is recommended for readability and portability reasons. I’m honestly surprised to see such a grammar-incompatible extension to C.

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

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Store the duration in seconds Use strototime to convert dates… May 16, 2026 at 9:57 am
  • Editorial Team
    Editorial Team added an answer Type 'FrameEventHandler' ... is not marked as serializable It's not… May 16, 2026 at 9:57 am
  • Editorial Team
    Editorial Team added an answer Use a System.Net.WebClient. Just call the OpenRead() and don't do… May 16, 2026 at 9:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Where can I browse the source code for any Android Open Source Project (AOSP)
My open-source Android application uses this in an SQL query: String.format(%f, someDoubleValue); Unfortunately, in
I cloned some of the trees from the Android Open Source Project to take
I know that the android plattform is open source. What I am interested in
I know that Google does some open source but a lot of their assets
In Android, is there a way to get a list of the zip files
in my Android application the file with name mainout.xml is creating, where ever this
i have made an android application for Project Build Target as Target name:: Android
When creating a new android project, the build target has two choices: Android 2.2,
I'm an experienced Android developer (if such thing exists) who has never worked with

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.