Globals (globals, statics, and multi-segment jump tables) are stored in a chunk of dynamic heap that is only allocated for the app when it is launched normally. This memory is available to the app via M68K register A5. The compiler knows this and generates code that accesses globals relative to A5. If you attempt to execute your code without A5 pointing to you globals, bad things happen.
Code that expects to be executed without a valid A5 should not use globals of any kind. There are alternatives. A common solution is to: 1) MemPtrNew() or MemHandleNew() a structure that contains all the info your code needs. Be sure to MemPtrSetOwner() to 0, so the memory is not automatically freed when your app exits, unless that's okay. 2) Optionally use a feature to remember the pointer or handle that you allocated in step #1. 3) Pass the pointer or handle as a user data pointer or reference in any API that sets up your code to be called back. Those situations that do not provide a user data pointer or reference can rely on the feature. YMMV. -----Original Message----- From: Dr. Vesselin Bontchev Subject: Global variables and special launch codes -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/