Re: ObjC question
Re: ObjC question
- Subject: Re: ObjC question
- From: "Hank Heijink (Mailinglists)" <email@hidden>
- Date: Mon, 21 Feb 2011 16:33:16 -0500
On Feb 21, 2011, at 4:22 PM, Tony Romano wrote: I don’t think that will work, that will pass in the address of the local variable, leftNote(sic) and not the one contained in the object. The address being passed in will be on the stack. I need to pass a reference to the one contained in the object node.
You're right. You'll have to rethink your interface, then. Why not pass the actual node around and ask for its address where you need it? Of course, this is without knowing what you're trying to accomplish, but I think that should work.
- (void)insert:(BTreeNode *)node node:(BTreeNode *)n;
Hank
On Feb 21, 2011, at 3:19 PM, Tony Romano wrote: -(void) insert: (BTreeNode **) node node:(BTreeNode *) n { …
// get the address of the left member [self insert:&[(*node) left] node:n]; // <--- error }
The compiler(GCC 4.2 or LLVM 1.6) is giving this error : address _expression_ must be an lvalue or a function designator.
The syntax you want is simply this:
BTreeNode *leftNote = [(*node) left]; [self insert:&leftNode node:n]; The return value for [(*node) left] may be an lvalue, but the _expression_ isn't. I don't know of a syntax that will let you get the address you want in one _expression_. However, in the interest of readability, I would prefer the two-line solution regardless.
Best, Hank
|
_______________________________________________
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