For examples of what I'm talking about, take a look at any of the SDK examples. I picked a few at random just now--ToDo.c, SubHunt.c, and SampleCalc.c--and each is riddled with static variables and functions. Another example: The Hello World example at the Palm Programmer's FAQ (http://tangentsoft.net/palmfaq/) has some functions marked static, others not, and I can't figure out why.
It doesn't really matter. Just let me get this straight: If I don't care whether my functions are externally accessible, and as long as I access my global variables during launch codes that allow it, then static is totally unnecessary, right? Thanks for the clarification, Trevor Jim Schram wrote: >At 3:43 PM -0700 2001/10/23, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> wrote: > >>I've noticed that pretty much every example of Palm OS code >>I've seen declares all variables and functions static. How >>come? >> > >I'm not sure what code you're looking at, but I'm going to guess that you're a little >confused about the difference between applying the static keyword to a function >versus to a variable... an unfortunate overloading of the term in C... static >functions are very different than static variables. > >When applied to a function, it makes sure the function is not visible outside the >file in which it's implemented. That's all. > >When applied to a variable, however, it essentially turns the variable into a global >variable, but not visible outside the file or function in which its defined (the >compiler access it as an offset from the A5 register rather than the SP register). It >is therefore only "available" during launch codes which provide global variable >storage. > >Hope that clears things up a bit... > >Regards, > >Jim Schram >Palm Incorporated >Partner Engineering > > >. > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
