首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

问一上c语言的static关键字有关问题

2012-10-14 
问一下c语言的static关键字问题在http://wenku.baidu.com/view/dfff38c55fbfc77da269b111.html百度文库中,

问一下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 這個檔案了吧.

自然就會把這些宣告和實做放進來.

热点排行