static functions: what this means?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

static functions: what this means?

997 Views
E_Dattilo
Contributor I
Hello,
i've seen in many examples that many functions are declared as "static", for example:
static void MyFunc() {
...
}
Could someone explain me what this keyword means? I am not able to find information about it on codewarrior help.

Thank you all,
Erik Dattilo
Labels (1)
0 Kudos
1 Reply

327 Views
SimonMarsden_de
Contributor II
Hi Erik

It's a standard keyword in ANSI C.

Used in the context you quote, it means that the function is private to the file which contains it. It you tried to call it from another file, you would get a link error.

It would even be possible (although poor style) to have two functions with the same name in different files, provided that both were declared as static.

Using 'static' for private routines is good programming practice because it helps to keep your code modular.

Simon
0 Kudos