Preprocessor concatenation questions
Preprocessor concatenation questions
- Subject: Preprocessor concatenation questions
- From: leenoori <email@hidden>
- Date: Thu, 14 Dec 2006 14:10:53 +0100
I'm writing Objective-C code in GNU99 mode (Xcode 2.4.1, GCC 4.0.1)
and trying to use the preprocessor to concatenate:
#define MY_MACRO(a, b) a ## b
Calling MY_MACRO(foo, bar) yields foobar, as one would expect.
But I would like to add another layer of indirection:
#define OTHER_MACRO(a) a
Calling MY_MACRO(OTHER_MACRO(foo), OTHER_MACRO(bar)) doesn't yield
foobar, it yields:
error: pasting ")" and "OTHER_MACRO" does not give a valid
preprocessing token
So evidently the concatenation is being performed prior to the
substitution, yielding the error. I can confirm that concatenation
takes place before substitution by doing the following:
#define foo FOO
#define bar BAR
MY_MACRO(foo, bar) /* yields foobar, not FOOBAR */
Any way to work around this and do what I want? I suspect the answer
is no, but wanted to ask the collective wisdom of the list first
before giving up.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden