• 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: Dynamic loading of System Frameworks???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic loading of System Frameworks???


  • Subject: Re: Dynamic loading of System Frameworks???
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Fri, 27 Jun 2003 21:43:34 +0100

On Friday, June 27, 2003, at 07:51 pm, Huyler, Christopher M wrote:

Ok, thanks for everyone's help with my Gestalt issues. I finally tracked the problem down to the loader. Although the symbols for all the functions were defined, the libraries in the CoreServices framework had not fully been initialized. This was because I was calling Gestalt inside a constructor.

Anyway, rather than let the loader decide when to initialize the libraries, I decided to load it myself. (See test program below) However I have one problem. I have to specifiy the full path of the library. Does anyone know if this will be a problem as Apple upgrades their libraries?

It might, especially as CarbonCore.framework is hidden within CoreServices.framework.

Why do you need to call Gestalt inside a static constructor? Can you not defer the call until later, for example by allocating the object as a singleton from your main() function? That would be a *lot* cleaner than trying to programmatically load the relevant framework so you can do the call at static construction time.

Static constructors are pretty evil, IMHO, because you cannot be certain whether frameworks (or libraries) will be initialised properly when your constructors are executed; after all, *they* may be using static constructors (or the GCC constructor function extension) themselves, and the order of construction is undefined, as I am sure you are aware. They are, of course, fine for simple objects, but I wouldn't use them for anything more complex than initialising member variables and maybe calling POSIX/BSD or C/C++ run-time functions (which should have been set-up by that point).

Kind regards,

Alastair.
_______________________________________________
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: 
 >Dynamic loading of System Frameworks??? (From: "Huyler, Christopher M" <email@hidden>)

  • Prev by Date: Re: New Panther UI Widgets?
  • Next by Date: Re: New Panther UI Widgets?
  • Previous by thread: Re: Dynamic loading of System Frameworks???
  • Next by thread: RE: Dynamic loading of System Frameworks???
  • Index(es):
    • Date
    • Thread