problem with macro expansion in GCC

Dhanabal Ekambaram Dhanabal@Zambeel.com
Tue Feb 6 10:33:00 GMT 2001


Hi David & Puneet,

Thanks for the comments.

I did try with concatenation already. It takes care of
the space between "N" and the ".".  But, I do get
a leading space wherever I use this macro.

If I have 
x = a.XXX(b);

I expect it to change to
x = a.b.ptr;

but, it changes to
x = a. b.ptr;

Thanks,
dhanabal

>   What happens if you try
>#define XXX(N) N ## .ptr  
>
> or perhaps
>
>#define CAT(a, b) a ## b
>#define XXX(N)    CAT(N, .ptr)
> 
>  One or other of those should work.  You can't ask macros to concatenate
>two strings just by writing them next to each other, you have to use
>the pre-processor pasting command ##.



More information about the Gcc-help mailing list