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,375
    Likes Received:
    388
    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,375
    Likes Received:
    388
    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,375
    Likes Received:
    388
    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:
    http://www.zimbio.com/Weight+Loss+Product/articles/vhVlGxsJ7D2/Phen+375+Review+Best+Way+Burn+Fat
    # this is symbol of preprocessor.
    Ex- #include<stdio.h>
    #include<conio.h>
    void main()
    {
    {
    }
    getch()
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice