Why does Borland compile with multiple definitions of same object in different C files while GCC does not?

泄露秘密 提交于 2019-12-01 18:17:38
ouah

Multiple external definitions of an object is undefined behavior in C. A common extension is to accept multiple definitions if they don't disagree (usually with same type and no initialization value).

C99 6.9p5 says:

If an identifier declared with external linkage is used in an expression (other than as part of the operand of a sizeof operator whose result is an integer constant), somewhere in the entire program there shall be exactly one external definition for the identifier; otherwise, there shall be no more than one"

and C99, 4.p2:

violation of a "shall" outside of a constraint implies UB

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!