• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Preprocessor concatenation questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Preprocessor concatenation questions
      • From: Michel Schinz <email@hidden>
  • Prev by Date: Re: executable obfuscator?
  • Next by Date: Re: Preprocessor concatenation questions
  • Previous by thread: Re: Why doesn't Apple's Installer let me choose architecture?
  • Next by thread: Re: Preprocessor concatenation questions
  • Index(es):
    • Date
    • Thread