• 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: Initialization Routine
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initialization Routine


  • Subject: Re: Initialization Routine
  • From: Andrew Kimpton <email@hidden>
  • Date: Wed, 25 Feb 2004 09:42:28 -0800

On Feb 25, 2004, at 9:21 AM, Randy Croucher wrote:

> Hello,
>
> I am building a dynamic library and want to have a function called
> when the library is first loaded.  If I set the "Initialization
> Routine" to something, like FooInit, I get a link error (undefined
> FooInit) even though I have defined the function (void FooInit()).
>
> What is the prototype for this function?  Or is there a different way
> to do this?
>

#pragma CALL_ON_LOAD InitMachOLibrary
extern "C" void InitMachOLibrary();
void InitMachOLibrary()
{
}

and

#pragma CALL_ON_UNLOAD TerminateMachOLibrary
extern "C" void TerminateMachOLibrary();
void TerminateMachOLibrary()
{
}

Is what I use - I believe Mach-O supports multiple call_on_load/unload
functions, though I haven't had a need to try it. Note this doesn't
need an explicit Xcode settings, it just uses the pragma features of
gcc

> Randy
>
Andrew 8-)
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Initialization Routine
      • From: Randy Croucher <email@hidden>
References: 
 >Initialization Routine (From: Randy Croucher <email@hidden>)

  • Prev by Date: Initialization Routine
  • Next by Date: Availability of physical CD of Xcode Tools 1.1?
  • Previous by thread: Initialization Routine
  • Next by thread: Re: Initialization Routine
  • Index(es):
    • Date
    • Thread