- 论坛徽章:
- 0
|
3.如果在不同的翻译单元就具有external linkage,也就是说确定两个文件的n是指同一个对象,那么引起undefined behavior。
依据:
ISO C11(N1570)
6.2.7/2 All declarations that refer to the same object or function shall have compatible type; otherwise, the behavior is undefined.
6.7.3/10 For two qualified types to be compatible, both shall have the identically qualified version of a compatible type; the order of type qualifiers within a list of specifiers or qualifiers does not affect the specified type.
否则(比如说extern int n;前面有static int n;的情况)就没这个问题。
|
|