Michael Harrison <[EMAIL PROTECTED]> wrote: > (my apologies if this is the third copy of this message, I've been > having difficulty posting to the list) > > I've recently had to divide my first palm app into two sections and > was suprised to discover that when I initiate a find (which my app > supports), my application would crash during a call to a function that > wasn't in the default section. > > Has anyone else run into this problem (and documented it someplace I > haven't been able to locate)? > > If Yes, did you find a solution other than merely making sure that > your search function only called routines in the default segment? >
This behaviour is documented in very many places, When your application is called with a non-standard launch code (as in find) global variables are not available. At least in gcc compiled programs, you need globals available in order to call functions in code sections 2 and higher. So the golden rule is: for all non standard launch codes do not rely on globals and do not call any functions outside the default code segment. PilotMain has to be in the default code segment. >From section 3.2.1 of the prc-tools documentation (http://prc-tools.sourceforge.net/doc/prc-tools_3.html): ----------------------------------------------------------------------------- The current implementation puts pointers to the code resources into the application's global data, and uses those pointers in the code emitted for each call in which the calling function and the called function are in different sections. This means that you must not attempt to call between different sections when globals are not available. In particular, all functions in your application called while processing a launch code that doesn't give you globals must be in the main code section. This always includes PilotMain, which is always called by the startup code for all launch codes. ----------------------------------------------------------------------------- You will find similar things in the PalmSource Documentation. E.g. in the Palm OS Companion section Responfing to Other Launch Codes: ----------------------------------------------------------------------------- In most cases, when you respond to other launch codes, you are not able to access global variables. Global variables are generally only allocated after an application receives sysAppLaunchCmdNormalLaunch (see Listing 2.2) or sysAppLaunchCmdGoto; so if the application hasn't received either of these launch codes, its global variables are usually not allocated and not accessible. In addition, if the application has multiple code segments, you cannot access code outside of segment 0 (the first segment) if the application has no access to global variables. ----------------------------------------------------------------------------- In other words, when everything else fails, read the manual ... Ton van Overbeek -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
