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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:34:59+00:00 2026-05-26T15:34:59+00:00

What is the correct output of preprocessing the following 3 lines under the C99

  • 0

What is the correct output of preprocessing the following 3 lines under the C99 rules?

#define y(x) x
#define x(a) y(a
x(1) x(2)))

BTW cpp under linux produces an error message, but I can’t see why the answer isn’t simply

1 2

Assuming cpp is correct and I’m wrong, I’d be very grateful for an explanation.

  • 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-26T15:34:59+00:00Added an answer on May 26, 2026 at 3:34 pm

    When a macro is found, the preprocessor gathers up the arguments to the macro and then scans each macro argument in isolation for other macros to expand within the argument BEFORE the first macro is expanded:

    6.10.3.1 Argument substitution

    After the arguments for the invocation of a function-like macro have been identified,
    argument substitution takes place. A parameter in the replacement list, unless preceded
    by a # or ## preprocessing token or followed by a ## preprocessing token (see below), is
    replaced by the corresponding argument after all macros contained therein have been
    expanded. Before being substituted, each argument’s preprocessing tokens are
    completely macro replaced as if they formed the rest of the preprocessing file; no other
    preprocessing tokens are available.

    So in this specific example, it sees x(1) and expands that, giving

    y(1 x(2)))
    

    It then identifies the macro call y(1 x(2)), with the argument 1 x(2) and prescans that for macros to expand. Within that it finds x(2) which expands to y(2 and then triggers the error due to there not being a ) for the y macro. Note at this point its still looking to expand the argument of the first y macro, so its looking at it in isolation WITHOUT considering the rest of the input file, unlike the expansion that takes place for 6.10.3.4

    Now there’s some question as to whether this should actually be an error, or if the preprocessor should treat this y(2 sequence as not being a macro invocation at all, as there is no ‘)’. If it does the latter then it will expand that y call to 1 y(2 which will then be combined with the rest of the input ()) and ultimately expand to 1 2

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

Sidebar

Related Questions

The following code produces wrong and inconsistent output with gcc (4.1.2 20080704) but correct
i installed php op code cache. php -v produces correct output, showing eaccelerator. but
Why does following code has a correct output? int GGT has no return statement,
I am getting the following output correctly: <?php echo number_format(12312.312,1); // Correct Output 12312.3
What is the correct output (meaning correct by the ECMA standard) of the following
Why would firefox give me the correct output but Chrome doesn't ? I am
SELECT * FROM title gives me the following output: title_number version_type hd_sd 1000046 Standard
I came across the following code snippet and needed to predict the output. My
The following code finds the correct hamiltonian cycle for a knight in a chessboard
TilesArray.tiles has a wrong output, alert(TilesArray.array); gives me the correct output with randomized numbers,

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.