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; }
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; }
## 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.
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.