Token Pasting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rudhir

    Token Pasting

    Hi Everyone,

    How can I paste tokens with a white space between them?

    Because,

    #define Paste(a,b) (a ## b)

    doesn't put a white space between the tokens.



    Thanks,
    Rudhir
  • Richard Heathfield

    #2
    Re: Token Pasting

    Rudhir said:
    Hi Everyone,
    >
    How can I paste tokens with a white space between them?
    >
    Because,
    >
    #define Paste(a,b) (a ## b)
    >
    doesn't put a white space between the tokens.
    #define Paste(a, b) (a b)

    if you want the parentheses, and

    #define Paste(a, b) a b

    if you don't.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • santosh

      #3
      Re: Token Pasting

      Rudhir wrote:
      Hi Everyone,
      >
      How can I paste tokens with a white space between them?
      >
      Because,
      >
      #define Paste(a,b) (a ## b)
      >
      doesn't put a white space between the tokens.
      Whitespace separates tokens. That will make it two tokens. So your
      question is misinformed.

      Comment

      • Rudhir

        #4
        Re: Token Pasting

        santosh wrote:
        Rudhir wrote:
        >
        >Hi Everyone,
        >>
        >How can I paste tokens with a white space between them?
        >>
        >Because,
        >>
        >#define Paste(a,b) (a ## b)
        >>
        >doesn't put a white space between the tokens.
        >
        Whitespace separates tokens. That will make it two tokens. So your
        question is misinformed.
        >
        OK. I get it. Operator '##' is used to make a single token by pasting
        different tokens together. So no question of whitespaces.

        It was a stupid question :) Humble Apologies.

        Thanks for the help.


        Rudhir

        Comment

        Working...