• 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 language question: C function within @implementation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obj-C language question: C function within @implementation


  • Subject: Re: Obj-C language question: C function within @implementation
  • From: "Sean McBride" <email@hidden>
  • Date: Thu, 3 Jul 2003 11:15:49 -0400
  • Organization: Matrox Electronic Systems Ltd.

Jeff Harrell (email@hidden) wrote on Thu, 3 Jul 2003 09:10:47 -0500:

>I've never seen anything quite like that. I can't tell what the intent
>is; is that supposed to be a class or an instance function? Since it
>casts the argument to an instance pointer, I'm going to assume that
>it's supposed to be an instance method.

The code is quite obviously awful and useless. It is merely a small
example illustrating what might be a compiler bug. But I'm not an Obj-C
expert so I wanted to check here. The real code was something like: 1)
in an Obj-C method create a pthread, passing it a C function pointer and
the 'self' of the calling class. 2) in the pthread function, use a cast
to get access to my Obj-C object 3) send a message to a protected member
of my object.

The error my coworker made (aside from step 3 itself :)) was to
accidentally put the C function within the @implementation block, and it
still compiles. I noticed this, and moved the C function out of the
@implementation block and it stopped compiling. I'm wondering if it
should never have compiled in the first place.

Here's the code again, with better names:

@interface MyController : NSObject
{
IBOutlet NSProgressIndicator* progressBar;
}
@end

@implementation MyController

void pthread_start_routine (void* arg)
{
MyController* controller = (MyController*)arg;
[controller->progressBar stopAnimation:controller];
}

@end

--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Mac Software Designer +1-514-822-6000
Matrox Electronic Systems Ltd. Montrial, Quibec, Canada
_______________________________________________
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.

  • Follow-Ups:
    • Re: Obj-C language question: C function within @implementation
      • From: daniel <email@hidden>
    • Re: Obj-C language question: C function within @implementation
      • From: Jeff Harrell <email@hidden>
References: 
 >Re: Obj-C language question: C function within @implementation (From: Jeff Harrell <email@hidden>)

  • Prev by Date: Re: basic nib connection frustration
  • Next by Date: Re: NSTableView w/ custom cell draws only first
  • Previous by thread: Re: Obj-C language question: C function within @implementation
  • Next by thread: Re: Obj-C language question: C function within @implementation
  • Index(es):
    • Date
    • Thread