• 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: Obj-C/C question (basic?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obj-C/C question (basic?)


  • Subject: Re: Obj-C/C question (basic?)
  • From: Ondra Cada <email@hidden>
  • Date: Sat, 19 Oct 2002 15:02:53 +0200

On Saturday, October 19, 2002, at 09:33 , Hisaoki Nishida wrote:

There's a method with the prototype:

int someCmethod(struct foo *arg);

Can't be. This is a function prototype, not a method one. In other words, there are no "plain C methods" -- they are plain functions.

(Well unless you do some quite serious hackery with the ObjC runtime, which I guess you don't)

int a = someCmethod((struct foo *)&myStruct);

But what if I want to pass it a return value from my obj-c method:
- (struct bar *)objcmethod;

How would I put the return value directly in someCmethod?

int a = someCmethod((struct foo *)*[someobj objcmethod]);

That wouldnt work... would it?

Surely it would not -- since the method returns a pointer, you should just use it (casted to get rid of the warning):

someCFunction((struct foo*)[o method]);

There's no reason to dereference it first by the *. It's exactly the same as with a ptr-returning function:

struct bar *anotherFunc();
...
someCFunction((struct foo*)anotherFunc());
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Obj-C/C question (basic?) (From: Hisaoki Nishida <email@hidden>)

  • Prev by Date: Re: Directory Enumeration in Cocoa
  • Next by Date: Re: Directory Enumeration in Cocoa
  • Previous by thread: Re: Obj-C/C question (basic?)
  • Next by thread: Re: [Q] Determining startup volume
  • Index(es):
    • Date
    • Thread