非静态声明考虑这些例子:下面的静态声明
static int a;
extern int a; //OK -- what linkage does the a have now?
static int a;
int a; //ERROR
extern int a;
static int a; //ERROR
int a;
static int a; //ERROR
extern int a;
int a; //OK as expected
int a;
extern int a; //OK as expected
为什么它是在第一个例子确定,但不是在第二?
就文件范围变量(全局范围)而言,当没有指定关键字时,它们具有外部链接和静态持续时间。
谢谢
据我所知,连接和存储持续时间功能是一个有点不同。
编辑: 我尝试用gcc 4.5.2编译-Wall -pedantic --std = C99
更多:http://c-faq.com/decl/static.jd.html你可以看到,第一个例子在那里工作过,但第二次却没有。但是,我不明白是什么让他们如此不同。
你可以更多地回答你的问题吗?因为在你第一次关心你评论确定,但是会产生一个错误,说“静态声明'a'遵循非静态声明” – 2011-08-30 05:56:34