static functions: what this means?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

static functions: what this means?

1,389 次查看
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 回复

719 次查看
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 项奖励
回复