• 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: Callbacks in C libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Callbacks in C libraries


  • Subject: Re: Callbacks in C libraries
  • From: Andrew Pinski <email@hidden>
  • Date: Sat, 14 Jun 2003 23:59:33 -0400

This is a GNU extension called functions inside functions.
A number of different languages support this but ISO/ANSI C does
not, Pascal is one though.
There really is no standard Objective-C so this could considered
standard Objective-C but I would not recommend it as it is bad practice
as it requires gcc.

Thanks,
Andrew Pinski

On Saturday, Jun 14, 2003, at 21:05 US/Eastern, Prachi Gauriar wrote:

On Saturday, June 14, 2003, at 07:47 PM, Eric Shepherd wrote:

What I've discovered is that I can prototype my callback in my class's header file, then actually include my callback function right inside the method that results in it being called, like this:

- (int) doScan: (ConfigRec *)cfgRec {
int CallbackFunc(ConfigRec *cfgRec, const DataRec *pRecord) {
[fileList addObject: [NSString stringWithCString: pRecord->filename]];
// More code here
return 0;
}

RunFileScan(cfgRec, CallbackFunc);
}

This works like a charm.

Is this standard C (ANSI or C99), or is it a GCC feature?

-Prachi
_______________________________________________
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.
_______________________________________________
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: Callbacks in C libraries
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Re: Callbacks in C libraries (From: Prachi Gauriar <email@hidden>)

  • Prev by Date: Re: Scripts for PackageMaker
  • Next by Date: How do i get a border around a view?
  • Previous by thread: Re: Callbacks in C libraries
  • Next by thread: Re: Callbacks in C libraries
  • Index(es):
    • Date
    • Thread