Thread: preprocessor

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    50

    preprocessor

    Why does the following line of code generate error as " pasting / and / doesnot generate a valid preprocessing token"? Can someone please help






    Code:
    #define comment /##/
       int main()
      {
        comment printf("hello");
        return 0;
       }

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,608
    ## is an operator for the preprocessor. It glues tokens together. See C preprocessor - Wikipedia, the free encyclopedia

    Also, by the time preprocessing happens, comments are removed.

  3. #3
    young grasshopper jwroblewski44's Avatar
    Join Date
    May 2012
    Location
    Where the sidewalk ends
    Posts
    294
    They are not valid tokens.

    Token-Pasting Operator (##) (C/C++)

    Also as whiteflags says, comments are removed during pre-processing (http://www.jncasr.ac.in/ccms/esc/programme/day8.pdf [search for "comment removal" or "Preprocessing"]). So that really doesn't make sense.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. preprocessor
    By pin2 in forum C Programming
    Replies: 5
    Last Post: 12-24-2009, 12:55 AM
  2. Preprocessor help
    By royen in forum C++ Programming
    Replies: 3
    Last Post: 05-14-2009, 10:56 AM
  3. preprocessor help
    By brunogon in forum C Programming
    Replies: 13
    Last Post: 06-16-2008, 11:14 AM
  4. Preprocessor
    By manutd in forum C++ Programming
    Replies: 5
    Last Post: 11-29-2006, 04:37 PM
  5. C preprocessor
    By Unregisterd in forum C Programming
    Replies: 1
    Last Post: 09-04-2001, 12:17 PM

Tags for this Thread