微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c – 更改名称的链接

在此代码中尝试更改名称i的链接.在C/C++中合法吗?
static int i = 2;
int i;

int main()
{
   return 0;
}

解决方法

在C中,您的代码格式不正确(您有多个变量i的定义),即需要一个符合标准的编译器才能发出错误消息

$3.2.1(C 03)

No translation unit shall contain more than one deFinition of any variable,function,class type,enumeration type or template.

在C99中,您的代码调用未定义的行为,因为6.2.2 / 7说

If,within a translation unit,the same identifier appears with both internal and external linkage,the behavior is undefined.

原文地址:https://www.jb51.cc/c/120091.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐