> At 18:44 2002-12-27 -0800, John Leung wrote:
> >I've finally get around to testing v9 today and I was testing out one
> >of those default project wizard.  More specifically: Palm OS Share
> >Library Wizard.  During the last step of the wizard, I was given the
> >choice of including MathLib into the project, and so I did.  When I
> >looked at the resulting source file "MathLib.c", I see the use of a
> >global variable "MathLibRef".  Is it really safe to use global
> >variable in a share library or is it a mistake in Codewarrior v9?
>
> That is a bug in the shared library wizard.  Thanks for the
> report.  MathLib.c is really designed to be used from an
> application.  While you can call MathLib from a shared library, you'll
need
> to find some other mechanism to hold the reference to MathLib, and you'll
> need to write your own wrappers (or at least do some macro trickery and
> include MathLib.c in your source file).

just store the global reference in a feature. you may need to make
some small changes elsewhere.. i normally have this code:

#ifndef USE_GLOBALS
  Globals *globals;

  // get globals reference
  FtrGet(appCreator, ftrGlobals, (UInt32 *)&globals);
#endif

inside each subroutine - if i have the USE_GLOBALS it'll use the globals
instead, where - at the top of the file i have defined:

#ifdef USE_GLOBALS
// globals object
static Globals gbls;
static Globals *globals;
#endif

i am sure to also set globals = &gbls; in my startup code *g* this way
it is transparent in a way. if you want it as an application, you set
USE_GLOBALS, if you want it as a hack, you dont :) quite easy.

---
Aaron Ardiri                           [EMAIL PROTECTED]
CEO - CTO                                              +46 70 656 1143
Mobile Wizardry                         http://www.mobilewizardry.com/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to