• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ObjC question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjC question


  • Subject: Re: ObjC question
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 21 Feb 2011 13:07:11 -0800

On Feb 21, 2011, at 12:19, Tony Romano wrote:

I'm trying to do this:

-(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.

I was assuming the return value for [[(*node) left]] is a lvalue (it's a pointer) and I should be able to obtain the address of that pointer but either you can't or the value returned from the message call to node is not a lvalue.

You're all tangled up. A return value is *never* a lvalue (if it was, you could write 'sqrt (4) = 3;'), so you're going to have to do this:

BTreeNode *temp = [(*node) left];
[self insert:&temp node:n];

but your code is still very smelly because it's not clear why you're passing around a pointer to the pointer to the left node (BTreeNode **). If the intention is to have 'insert:node:' return the left node pointer to its caller, why not just use a return value?

BTW, this the wrong list for this question, since it's not about Xcode. The correct list is probably email@hidden.


 _______________________________________________
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

  • Follow-Ups:
    • Re: ObjC question
      • From: Tony Romano <email@hidden>
References: 
 >ObjC question (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: ObjC question
  • Next by Date: Re: ObjC question
  • Previous by thread: Re: ObjC question
  • Next by thread: Re: ObjC question
  • Index(es):
    • Date
    • Thread