加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 更改名称的链接

发布时间:2020-12-16 04:55:04 所属栏目:百科 来源:网络整理
导读:在此代码中尝试更改名称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
在此代码中尝试更改名称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 identi?er appears with both internal and external linkage,the behavior is unde?ned.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读