Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / September 2004



Tip: Looking for answers? Try searching our database.

CALL_ON_LOAD, CALL_ON_MODULE_BIND, etc.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ki Suk Hahn - 28 Sep 2004 15:49 GMT
I've searched the newsgroup for threads related to CALL_ON_LOAD,
CALL_ON_MODULE_BIND, etc. but have not found an answer to my question.

If anyone can help it will be appreciated.

Using CW 9.1 on OS X 10.3, XCode 1.1, 10.3.0SDK

I'm trying to create a Mach-O framework that will call initialization
and termination routines when loaded and when terminated.  Some people
have reported success using CALL_ON_UNLOAD but I cannot get my simple
toy Mach-O framework to execute its initialization and termination
routines using CALL_ON_LOAD/CALL_ON_MODULE_BIND and
CALL_ON_UNLOAD/CALL_ON_MODULE_TERM.

The framework source has:

#pragma CALL_ON_LOAD _init //(also tried CALL_ON_MODULE_BIND)

extern void _init()
{
  // init code
}

The framework is linked with dylib1.o (Nov 2003).  

I am able to get the _init() to run by putting it in the "Init Entry
Point" in the target settings, but would like to use the CALL_ON_*
since I have a termination routine to call as well.

Thanks for any help or advice on this.

Ki Suk Hahn
Adriaan van Os - 28 Sep 2004 18:11 GMT
> I am able to get the _init() to run by putting it in the "Init Entry
> Point" in the target settings, but would like to use the CALL_ON_*
> since I have a termination routine to call as well.

What you see is a Mac OS X design restriction: frameworks (dylibs) are
loaded automatically and they can not be unloaded, so (...) there is no
termination routine. Bundles and loadable bundle packages can be loaded
and unloaded manually and they do have termination routines. They are
the best choice for plugins (if that is what you want).

Regards,

Adriaan van Os
MW Ron - 28 Sep 2004 20:18 GMT
>I've searched the newsgroup for threads related to CALL_ON_LOAD,
>CALL_ON_MODULE_BIND, etc. but have not found an answer to my question.
[quoted text clipped - 9 lines]
>routines using CALL_ON_LOAD/CALL_ON_MODULE_BIND and
>CALL_ON_UNLOAD/CALL_ON_MODULE_TERM.

All I know is the pragmas

#pragma CALL_ON_MODULE_BIND <init_function>
#pragma CALL_ON_LOAD <init_function>

This pragma applies to MacOS X Mach-O only. Specifies that init_function
shuld be called when the dynamic library or bundle is loaded.

#pragma CALL_ON_MODULE_TERM <term_function>
#pragma CALL_ON_UNLOAD <term_function>

This pragma applies to MacOS X Mach-O only. Specifies that term_function
shuld be called just before the dynamic library or bundle is unloaded.

Other than that, you might try upgrading to CW 9.3  and see if that
makes a difference.  More than that I'd need to know more.

Ron  

>The framework source has:
>
[quoted text clipped - 10 lines]
>Point" in the target settings, but would like to use the CALL_ON_*
>since I have a termination routine to call as well.

Signature

Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
       --   http://www.metrowerks.com/community  --

Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com

Ki Suk Hahn - 30 Sep 2004 14:41 GMT
> >I've searched the newsgroup for threads related to CALL_ON_LOAD,
> >CALL_ON_MODULE_BIND, etc. but have not found an answer to my question.
[quoted text clipped - 28 lines]
>
> Ron  

To Ron and Adriaan,

Thanks for your replies.  A colleage at work suggested  putting the
pragmas after the function definitions, and that worked. (I used
CALL_ON_MODULE _BIND).

Sorry I wasn't more specific about whether I was making a plug-in or
whether I was using Mach-O, etc.

Ki Suk Hahn
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.