And just in case you're thinking about this, I'm one of the many people that have not
succeeded in getting any C++ class structure
to work when globals aren't available. So if you have C++ functions, don't even
bother leveraging them when globals are absent.
(Side note - how many of these limitations could be bypassed if people felt a need to
do so? For example, the only advantage I see
to limiting code segments to +/- 32K is a slight speed optimization so you avoid a
separate ADD IMM isntruction... it's all in the
compilation...)
Ben Combee wrote:
> > I am having a hard time understanding the restrictions on access to global
> > variables in the PalmOS environment. The various documents I have read
> > state that global variables are not available for certain launch codes.
> > Does this mean the variables themselves are not accessible, or have they
> > merely not been initialized?
>
> Typically on the Palm, global variables are stored in a region on the heap
> which is pointed to by the A5 register. In a launch situation where you
> don't have global access, the A5 register is already is use storing the
> global pointer for the active application. This region that A5 points to
> also has some system data, so changing it to point to a "local" global pool
> for the sublaunched program would affect system stability.
>
> > Can I initialize them? Since the event
> > handling architecture in PalmOS does not allow for including call data in
> > event handlers, it is pretty difficult to get around using global
> variables.
>
> The usual method is to use features, which can be used like globals --
> allocate dynamic space for a structure with all your "global" data, then
> store the pointer in a feature which you can retrieve using an API call in
> any subroutines which need them.
>
> --
> Ben Combee
> Veriprise Wireless <http://www.veriprise.com>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see
>http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/