Re: Preprocessing within @"SOMEDEFINEDSTRING"
Re: Preprocessing within @"SOMEDEFINEDSTRING"
- Subject: Re: Preprocessing within @"SOMEDEFINEDSTRING"
- From: Ken Thomases <email@hidden>
- Date: Fri, 20 Mar 2009 13:11:58 -0500
On Mar 20, 2009, at 12:55 PM, Daniel Luis dos Santos wrote:
I am trying to do the thing in the subject. I define a constant with
#define SOMECONST aStringWithoutWhiteSpace
, later in the code I have a call to a C function defined in a .m
that is called like :
aFunctionCall(@"SOMECONST")
The method ends up creating a directory in which the last path
component is the function argument. The #define is not preprocessed
and instead of having a directory named after the constant I get the
constant name in the path.
Shouldn't the preprocessor see this constant before compiling and
replace it ?
No, it shouldn't. The preprocessor doesn't look into string literals,
and we should all be glad.
You can play games with the # stringify operator within macros, but
there's a trick to it that I forget. I think you have to double up on
the macros. Ah, here it is: http://everything2.com/title/stringize%20macro%20macro%20hack
For an Objective-C NSString literatal, you can either wrap
XSTR(SOMECONST) inside CFSTR(), or you can take advantage of the fact
that the C compiler will concatenate adjacent string literals and do:
@"" XSTR(SOMECONST)
Regards,
Ken
_______________________________________________
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