Re: CFSTR and double-double quotes
Re: CFSTR and double-double quotes
- Subject: Re: CFSTR and double-double quotes
- From: Greg <email@hidden>
- Date: Sat, 26 Jul 2008 14:59:13 -0400
It's just padding it with zero's.
"" = '\0'
Which is probably why passing a variable didn't work. You can do this:
char *yum = "fee" "fi" "fo" "fum";
And the compiler will concatenate that into: "feefifofum", but you
can't do this:
"asdf" somevar "poo"
Because the compiler doesn't know the value of somevar at compile time.
- Greg
On Jul 26, 2008, at 2:40 PM, Ivan Galic wrote:
Hi,
I've been writing a utility function for getting a path within the
bundle from the filename. For that, I used the function
CFBundleCopyResourceURL, which needs some CFStringRefs. I saw
somewhere on the net an example like this:
CFSTR("somefile")
and it worked fine. However, when I put it inside a function which
takes const char * parameters, it didn't:
void SomeFunction(const char *filename)
{
...
CFBundleCopyResourceURL(mainBundle, CFSTR(filename), ...);
}
I eventually solved the problem using CFStringCreateFromCString, but
there's one thing I don't understand. I thought a string literal
should be treated by the compiler just as const char*, but obviously
it isn't. Further, I've found in the CoreFoundation headers the
definition of CFSTR which uses a syntax I've never seen before:
#ifdef __CONSTANT_CFSTRINGS__
#define CFSTR(cStr) ((CFStringRef)
__builtin___CFStringMakeConstantString ("" cStr ""))
#else
#define CFSTR(cStr) __CFStringMakeConstantString("" cStr "")
#endif
Can anyone explain what do the double-double quotes mean? Is it
something Apple specific? I've never seen it before in a C program...
Thanks,
Ivan
_______________________________________________
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:
@kinostudios.com
This email sent to email@hidden
_______________________________________________
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