"Jun-Kiat Lam" <[EMAIL PROTECTED]> wrote in
message news:69996@palm-dev-forum...
>
> > Well, sure.  But doesn't that mean he's at home playing on his
> > computer instead of at work playing on his computer?
>
> Hehehe...no I think this time it's for real. We checked. :-)
>
> -- jkl

Hey, I was in Paris playing on my sister's computer! :)

C's rules on static local variables are similar to C++.  The thing to
note is that C does allow initializers that do work.  You could write

void foo()
{
    static int x = bar();
}

In that case, x is like a global variable that can only be seen inside
foo, but it can't be initialized until foo is entered.  If the
initializer was a constant expression, it could be part of the
initialized data, but otherwise, its value is indeterminate until the
first entry to the function (or scope) containing it.

Note: in the case above, x would only be initialized on the first entry
to foo().  This implies that the compiler has to store a second,
initialized global, that is used to track the initialization of the
first.  A smart compiler will eliminate this if its able to initialize
the variable from a constant expression.



-- 
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