Re: Accessing variable set in 'Other C Flags'
Re: Accessing variable set in 'Other C Flags'
- Subject: Re: Accessing variable set in 'Other C Flags'
- From: Greg Parker <email@hidden>
- Date: Mon, 8 Jun 2009 13:40:57 -0700
On Jun 8, 2009, at 1:18 PM, Miles wrote:
I was reading on a couple blogs about setting 'Other C Flags' to
-DTARGET_NAME=${TARGET_NAME} so that I can have multiple targets and
differentiate between them in my code. But when I try to access it
in my
code it keeps treating the value of TARGET_NAME as a variable.
In other words, if TARGET_NAME = "FullVersion", and I try to check it:
NSString *version = [NSString stringWithFormat:@"%@", TARGET_NAME];
I get the error: 'FullVersion' undeclared (first use in this function)
How can I access it and treat it as a string???
Try one of these:
1. Add quotes to your -D. The actual syntax depends on your shell /
build environment; you need to protect the quotes from everyone except
the compiler itself. Try something like this:
-DTARGET_NAME=\"${TARGET_NAME}\"
2. Use the # operator to turn your unquoted identifier into a string:
#define STRING(x) #x
[NSString stringWithFormat:@"%s", STRING(TARGET_NAME)]
Note that both of these turn TARGET_NAME into a C string, so you'd
need to use %s instead of %@. Producing a @"" string or CFSTR() string
is left as an exercise for the reader.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden