Token Pasting operator

Neil Booth neil@daikokuya.co.uk
Wed Jul 30 07:21:00 GMT 2003


Srivatsan S wrote:-

> Hi,
> 
> I have the following piece of code which compiles properly with gcc version 2.95.3, but gives warnings in 3.2.3. This code piece uses token pasting operator in C (##) for string concatenation.
> 
> 
> #define SETVALUE(x,y)  x##y
> 
> main()
> {
>     char z[20];
>     sprintf(z, "%s", SETVALUE("test ", " the program" ));
>     printf("z=%s \n", z );
> }
> 
> How to compile this successfully on 3.2.3 without warnings?

Remove the ##.

Neil.



More information about the Gcc mailing list