Static vs global

前端 未结 5 504
不知归路
不知归路 2020-11-28 19:57

If I have a C file like below, what is the difference between i and j?

#include 
#include 

static i         


        
5条回答
  •  日久生厌
    2020-11-28 20:38

    i has internal linkage so you can't use the name i in other source files (strictly translation units) to refer to the same object.

    j has external linkage so you can use j to refer to this object if you declare it extern in another translation unit.

提交回复
热议问题