static functions: what this means?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

static functions: what this means?

1,391件の閲覧回数
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
ラベル(1)
0 件の賞賛
返信
1 返信

721件の閲覧回数
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 件の賞賛
返信