This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: problem with macro expansion in GCC


>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;
>

   Hi Dhanabal,

 You have to use concatenation *again* to join "a" and "XXX(b)"; it is 
part of how the preprocessor is defined to work that it won't just 
concatenate tokens like that.  Macro definitions are special items and
the spaces are introduced deliberately to prevent them from unexpectedly
joining onto other things.

 x = CAT(a, XXX(b));

        DaveK
-- 
we are not seats or eyeballs or end users or consumers.
we are human beings - and our reach exceeds your grasp.
                    deal with it.                      - cluetrain.org 

>-----Original Message-----
>From: Dhanabal Ekambaram [mailto:Dhanabal@Zambeel.com]
>Sent: 06 February 2001 18:32
>To: David Korn; 'Puneet Singhal'; gcc-help@gcc.gnu.org
>Subject: RE: problem with macro expansion in GCC
>
>
>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 ##.
>


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]