问一下c语言的static关键字问题
在http://wenku.baidu.com/view/dfff38c55fbfc77da269b111.html百度文库中,看到关于c关键字static的解释
然后我写了
test_static.c
- C/C++ code
#include<stdio.h>static int total;int f(){ static int x=9; return x--;}test_static2.c
- C/C++ code
#include<stdio.h>#include"test_static.c"//extern int f();int main(){ printf("%d",total); f(); return 0;}为什么total能访问到?而且f连声明都不需要,(extern int f();这个不要)都可以通过。这是怎么回事?
我用的是codeblocks gcc的编译器,关闭了编译选项-std=gnu++0x
[解决办法]
因你有include test_static.c 案了吧.
自然就把些宣告和做放.