Re: warning: argument to '&' not really an lvalue
Re: warning: argument to '&' not really an lvalue
- Subject: Re: warning: argument to '&' not really an lvalue
- From: Marshall Clow <email@hidden>
- Date: Fri, 8 Feb 2008 14:05:15 -0800
At 1:59 PM -0800 2/8/08, Jerry Krinock wrote:
NSURL* and CFURLRef are "toll-free bridged". So, for example, if a
function requires a CFURLRef*, I'd write this:
NSURL* aURL ;
LSSharedFileListItemResolve(
item,
0,
&(CFURLRef)aURL,
NULL) ;
But in Xcode 3.0 with the 10.5 sdk, this gives me:
warning: argument to '&' not really an lvalue;
this will be a hard error in the future
When you cast (CFURLRef)aURL, you get a value, not a variable.
You can't take the address of a value.
Consider:
float f = 2.3F;
int *foo = &(int) f;
What would "foo" point to here?
I don't get what they mean and can't find that searching Developer
Tools Reference Library.
I can avoid the warning by being more pedantic:
CFURLRef cfURL ;
CFURLRef* cfURL_p = &cfURL ;
LSSharedFileListItemResolve(
item,
0,
cfURL_p,
NULL) ;
NSURL* aURL = (NSURL*)*cfURL_p ;
Is there a simpler way to avoid the warning?
Both snippets above work. I think my original snippet is fine. Why
doesn't Xcode like it?
You can write:
(CFURLRef*) &aURL
instead of
&(CFURLRef) aURL
And that will both work, and be correct.
--
-- Marshall
Marshall Clow Idio Software <mailto:email@hidden>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
_______________________________________________
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