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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:23:44+00:00 2026-06-17T22:23:44+00:00

I read little gnu online docs about macro and little confused about this sentence:

  • 0

I read little gnu online docs about macro and little confused about this sentence:

Also multi-character operators such as += can be formed by token pasting

So I wander if macro can perform compound assignments,How?

  • 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-06-17T22:23:45+00:00Added an answer on June 17, 2026 at 10:23 pm
    #define PASTE(a,b) a##b
    int foo;
    foo PASTE(+,=) 2;
    

    The only time I’ve ever seen this be useful was in the inner loop of a bytecode interpreter, which tends to look like a gigantic case statement with very repetitive code in each arm:

    case OP_add: {
        if (sp < 2) goto underflow;
        double x = stack[--sp];
        stack[sp-1] += x;
    } break;
    

    Repeat for each supported binary arithmetic operator. With the ability to token-paste, you can generate them all from a macro:

    #define ARITH_BINOP(name, oper) case OP_##name: { \
        if (sp < 2) goto underflow; \
        double x = stack[--sp]; \
        stack[sp-1] oper##= x; \
    } break /* deliberate absence of semicolon */
    

    and then, in the switch, you can just write

    ARITH_BINOP(add, +);
    ARITH_BINOP(sub, -);
    ARITH_BINOP(mul, *);
    /* etc */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am little bit confused about this statement that I read in a book
I only read a little bit about this topic, but it seems that the
I've read a little about comet and also APE. Which one is better? I
I'm looking for a make platform. I've read a little about gnu make, and
I just read little bit about macro and was trying to create the one
Yestereday I read a little about threading in ruby (like this article ), and
I would like to read a little more about the + that is usually
I've read similar questions here but I'm still a little confused. MyCollection extends ArrayList<MyClass>
i´ve read a little about java's structure and could someone tell me if my
I've read a little bit about the cluster module introduced in Node.js 0.8, but

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.