At 3:43 PM -0700 2001/10/23, [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/

Reply via email to