---
title: "Linux下关于const和static的总结"
author: "lu007heng"
date: "2011-03-26T09:58:51Z"
tags: ["C", "C#", "C++", "HTML", "Linux"]
categories: ["操作系统"]
slug: "linux-const-static"
draft: false
lastmod: "2011-03-26T09:58:51Z"
id: 975844
url: "https://lu007heng.iteye.com/blog/975844"
---

维基百科上有很好的表述，我只想用一些简单的话来概括一下，以求能在最少的阅读量下清晰地明白他们的用法。

    const就是define something that is consistent,用它声明的变量以后就不能改了。注意const指针那个地方，是指针是不变的还是指针指向的内容不变。

    static means create something that is visible to the local file. 因为C下面一个文件中声明的东西，比如说函数，在同工程的其他文件中也是可以调用的，用static声明了之后，他就只可以本地使用了。当然了，Technically, "static" has other meanings in C related to persistant storage of local variables in functions across function calls.

 

 

一个讲的比较透彻的链接：[http://www.linuxforums.org/forum/programming-scripting/164742-static-const-c.html](http://www.linuxforums.org/forum/programming-scripting/164742-static-const-c.html)