Re: Initialization Routine
Re: Initialization Routine
- Subject: Re: Initialization Routine
- From: Randy Croucher <email@hidden>
- Date: Wed, 25 Feb 2004 14:36:44 -0800
Andrew,
Thank you, that worked. Now I am wondering why this initialization
function doesn't get hit right when the app launches (the app links to
my dylib). My application has already done some stuff before ever
getting to the init function in the dylib. I wonder if it is lazy
about calling the init until something is used out of the dylib? If
this is the case, I guess I should be okay. I am just worried that
someone will make a call into my dylib before it is initialized.
My next question is about static class constructors not being called on
load, but I think I will post that in a separate message if I don't
figure it out in the next hour or so.
Thanks,
Randy
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.