# 全局变量和静态全局变量的区别

**URL:** <https://www.shiqidu.com/t/topic/562>\
**Category:** 开发调优\
**Tags:** C-C-Obj-C\
**Created:** [2019 年3 月 6 日 00:59 UTC](https://www.shiqidu.com/t/topic/562 "2019-03-06T00:59:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2019 年3 月 6 日 00:59 UTC](https://www.shiqidu.com/t/topic/562/1 "2019-03-06T00:59:06Z")

</div>

二者区别主要是作用域的区别，全局变量的作用域是整个程序，即既能在当前文件中使用，也能在当前文件包含的其他文件中使用，而静态全局变量则只能在当前文件中使用。

![alt text](https://discourse.shiqidu.com/upload/discussion/20190306/7b657caca20e0de152d7eb10d3b58d30_origin.png)
