preprocessor

ghostrider12345's Avatar, Join Date: Mar 2013
Newbie Member
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;
}
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Comment is /**/ and not /##/ BTW
0
ghostrider12345's Avatar, Join Date: Mar 2013
Newbie Member
Quote:
Originally Posted by shabbir View Post
Comment is /**/ and not /##/ BTW
I know that Sir this question deals with pasting / and / which surely forms a single line comment
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
So why you think /##/ would give you output as //?
0
ghostrider12345's Avatar, Join Date: Mar 2013
Newbie Member
Its a preprocessor token pasting operator which joins its operands to make a valid token!!!
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
http://gcc.gnu.org/onlinedocs/cpp/Concatenation.html

It says clearly and I quote
Quote:
Keep in mind that the C preprocessor converts comments to whitespace before macros are even considered. Therefore, you cannot create a comment by concatenating `/' and `*'. You can put as much whitespace between `##' and its operands as you like, including comments, and you can put comments in arguments that will be concatenated. However, it is an error if `##' appears at either end of a macro body.
0
aroraaisha's Avatar, Join Date: Jul 2011
Light Poster
# this is symbol of preprocessor.
Ex- #include<stdio.h>
#include<conio.h>
void main()
{
{
}
getch()
}