请参阅同一翻译单元中的以下代码:
static int global_var; // file scope in C and global namespace scope in C++
// internal linkage
void f(void)
{
static int local_var; // block scope in C and local scope in C++
// no linkage
}
Run Code Online (Sandbox Code Playgroud)
我的理解是这样的:
我的问题:
编辑
在James Kanze的回答和评论之后,我现在能够构建一个示例,显示内部和无链接属性之间的区别:
static int i; // definition
// static storage
// internal linkage
void f(void)
{
extern int i; // declaration
// refers to the …
Run Code Online (Sandbox Code Playgroud)