Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
solution for macro
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
dhun  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 00:23
Newsgroups: comp.lang.c++.moderated
From: dhun <mdhua...@gmail.com>
Date: Sat, 7 Nov 2009 18:23:50 CST
Local: Sun 8 Nov 2009 00:23
Subject: solution for macro
Hi All,
I have a following kind of situation.

#define i(p) p
#define r(x) i(in)##_##x

int main(){
#define in a
int a,a_b;
a = r(b);
#undef in

}

where I need to construct a symbol ab, at the place where code is
executed.

A g++ -E test.c, however insert a space between a and b.

What could be possible solution for this?

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bart van Ingen Schenau  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 15:52
Newsgroups: comp.lang.c++.moderated
Follow-up To: comp.lang.c++.moderated
From: Bart van Ingen Schenau <b...@ingen.ddns.info>
Date: Sun, 8 Nov 2009 09:52:30 CST
Local: Sun 8 Nov 2009 15:52
Subject: Re: solution for macro

To get the correct substitution for all macro parameters, you need
another two levels of macros.
This example give the required result:

#define i(p) p
#define r(x) r2(i(in),x)
#define r2(p,q) r3(p,q)
#define r3(x,y) x##_##y

int main(){
#define in a
int a,a_b;
a = r(b);
#undef in

}

Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://c-faq.com/
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google