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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:31:30+00:00 2026-05-24T17:31:30+00:00

Alleged interview question and answer here . Will the following code compile (in C)?

  • 0

Alleged interview question and answer here.

Will the following code compile (in C)?

#define X 8;
int main(void)
{
    ++X; // will this line compile?
}`

I am no expert in C, but I know some C++ and thought: of course not, you cannot increment the number 8, it is an rvalue. Of course the preprocessor replaces the X with the 8 before trying to compile, and when it does try to compile, it will fail for that very reason. Then again, I am the one reading interview question websites so then I thought who knows…

Here is the explanation given:

“Strictly speaking, the operand of the prefix (or postfix) increment operator must be a non-modifiable lvalue. Now that we know what an lvalue is, we must ask ourselves if X is an lvalue. X is a macro, which means that it does not identify a place in memory – macros use simple text replacement via the preprocessor. Because macros don’t exist in a region of memory, they are not lvalues. This means that X can not be used as an operand of the prefix increment operator. Thus, the code shown above will not compile.”

Is this explanation as bunk as I think it is?

How many errors can you find above? I think maybe that should be the interview question…

And this is just funny:

“Intuitively, you might be able to say that the code above will not compile – without knowing exactly why. However, in an interview situation, you will be expected to provide some reasoning like what’s given above. Simple yes or no answers just won’t cut it in an interview.” (!)

  • 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-24T17:31:32+00:00Added an answer on May 24, 2026 at 5:31 pm

    Is this explanation as bunk as I think it is?

    Yes.

    “Strictly speaking, the operand of the prefix (or postfix) increment operator must be a non-modifiable lvalue…

    What? A non-modifiable lvalue is something like const int n; – you can take its address (via &) but you can’t assign to it (via =, +=, or ++). You can’t increment something that’s not modifiable.

    To quote the standard (6.5.3.1 paragraph 1):

    The operand of the prefix increment or decrement operator shall have qualified or
    unqualified real or pointer type and shall be a modifiable lvalue.

    Ahem.

    X is a macro, which means that it does not identify a place in memory – macros use simple text replacement via the preprocessor.

    This is bogus. Macros don’t exist in the C language*. They’re part of the preprocessor, which has no concept of lvalues, rvalues, expressions, or memory. This particular macro expands to an integer constant, which is an rvalue, but macros themselves have nothing to do with any of the above. See Steve Jessop’s answer for a counterexample of a macro being an lvalue.

    The correct answer is that the statement expands to ++8, and since 8 is an rvalue it cannot be used as an argument to ++ (in either form), and so it will not compile. Also, depending on whether you intend this code to be compiled as C89 or C99, leaving main without an explicit return value probably gives undefined behavior.

    * If this is going to be the accepted answer, I suppose I ought to clarify this bit: the preprocessor is a part of the C programming language. It is specified in the C standard, and a compiler has to implement preprocessing in order to be a C compiler. However, the C “language” (i.e. the syntax, semantics, library, etc.) doesn’t interact with the preprocessor – once you get to the stage where you start dealing with lvalues and rvalues, the preprocessor has long since been done and all macros are fully expanded. The macros themselves don’t have any place in the syntax, since they aren’t part of the “language.” There was some debate (in Steve Jessop’s answer) about whether the use of the term “language” here is misleading, and I agree with him that it is, I just can’t find a better word to use instead.

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

Sidebar

Related Questions

I'm just implementing a JavaEE assignment I was given on an interview. I have
We're migrating from StarTeam (aka the horrible) to SubVersion (aka the alleged great). We've
I know this is probably simple and has probably been asked before, but I'm
In the following two cases, if Customer is disposable (implementing IDisposable), I believe it
Is it possible to read binary MATLAB .mat files in Python? I've seen that
Python noob trying to learn Pylons. I'm using the QuickWiki tutorial ( http://pylonshq.com/docs/en/1.0/tutorials/quickwiki_tutorial/ )
The IT department of a subsidiary of ours had a consulting company write them
I'm trying to find duplicate keys so that they can be addressed and made
Several times I've read that unpack() is faster than substr() , especially as the
I have a simple HTMLCommandButton that I want to cause a rerender to another

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.