What does “static” mean in C?

后端 未结 19 1890
误落风尘
误落风尘 2020-11-21 05:18

I\'ve seen the word static used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)?

19条回答
  •  隐瞒了意图╮
    2020-11-21 05:19

    There are 2 cases:

    (1) Local variables declared static: Allocated in data segment instead of stack. Its value retains when you call the function again.

    (2) Global variables or functions declared static: Invisible outside compilation unit (i.e. are local symbols in symbol table during linking).

提交回复
热议问题