1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

preprocessor

Discussion in 'C' started by ghostrider12345, Mar 12, 2013.

  1. ghostrider12345

    ghostrider12345 New Member

    Joined:
    Mar 12, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Why does the following line of code generate error as " pasting / and / doesnot generate a valid preprocessing token"? Can someone please help



    #define comment /##/
    int main()
    {
    comment printf("hello");
    return 0;
    }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Comment is /**/ and not /##/ BTW
     
  3. ghostrider12345

    ghostrider12345 New Member

    Joined:
    Mar 12, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I know that Sir this question deals with pasting / and / which surely forms a single line comment
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    So why you think /##/ would give you output as //?
     
  5. ghostrider12345

    ghostrider12345 New Member

    Joined:
    Mar 12, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Its a preprocessor token pasting operator which joins its operands to make a valid token!!!
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    http://gcc.gnu.org/onlinedocs/cpp/Concatenation.html

    It says clearly and I quote
     
  7. aroraaisha

    aroraaisha New Member

    Joined:
    Jul 13, 2011
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    virenderseo2
    Location:
    virenderseo2
    Home Page:
    # this is symbol of preprocessor.
    Ex- #include<stdio.h>
    #include<conio.h>
    void main()
    {
    {
    }
    getch()
    }
     

Share This Page