public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Korn <dkorn@pixelpower.com>
To: 'Dhanabal Ekambaram' <Dhanabal@Zambeel.com>,
	'Puneet Singhal' <puneet@opussoft.com>,
	gcc-help@gcc.gnu.org
Subject: RE: problem with macro expansion in GCC
Date: Wed, 07 Feb 2001 01:36:00 -0000	[thread overview]
Message-ID: <718D38CAB6E0D011B2C90060970C28A5642678@EXCHANGESERVER> (raw)

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

             reply	other threads:[~2001-02-07  1:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-07  1:36 David Korn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-02-06 10:33 Dhanabal Ekambaram
2001-02-06 10:15 David Korn
2001-02-05 19:06 Dhanabal Ekambaram
2001-02-05 20:50 ` Puneet Singhal
2001-02-06 12:35 ` Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=718D38CAB6E0D011B2C90060970C28A5642678@EXCHANGESERVER \
    --to=dkorn@pixelpower.com \
    --cc=Dhanabal@Zambeel.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=puneet@opussoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).