How am I able to access a static variable from another file?

How am I able to access a static variable from another file? Doesn't static variable have a file scope? bash-3.2$ ls a.c b.c bash-3.2$ cat a.c #include static int s = 100; int fn() { /* some code */ } bash-3.2$ cat b.c #include #include "a.c" extern int s; int main() { printf("s = %d \n",s); return 0; } bash-3.2$ gcc b.c bash-3.2$ a.exe s = 100
Is it not violating or bypassing the definition of a static variable that it has file scope only and can not be accessed from another file?

以上就是How am I able to access a static variable from another file? 的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏