NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages

The static keyword is used to alter a variable declaration so that the variable is allocated statically - the lifetime of the variable extends across the entire run of the program - while having the same scope as variables declared without the static keyword.

Note that the initialization of automatic and static variables is quite different. Automatic variables (local variables are automatic by default, unless you explicitly use static keyword) are initialized during the run-time, so the initialization will be executed whenever it is encountered in the program. Static (and global) variables are initialized during the compile-time, so the initial values will simply be embeded in the executable file itself.

void func() {
static int x = 0; // x is initialized only once across three calls of func()
NumOut(0, LCD_LINE1, x); // outputs the value of x
x = x + 1;
task main() {
func(); // prints 0
func(); // prints 1
func(); // prints 2