When to use static keyword before global variables?

前端 未结 8 520
再見小時候
再見小時候 2020-11-28 20:12

Can someone explain when you\'re supposed to use the static keyword before global variables or constants defined in header files?

For example, lets say I have a head

8条回答
  •  爱一瞬间的悲伤
    2020-11-28 20:51

    The static keyword is used in C to restrict the visibility of a function or variable to its translation unit. Translation unit is the ultimate input to a C compiler from which an object file is generated.

    Check this: Linkage | Translation unit

提交回复
热议问题