Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有int a[]一个 C 文件。现在在另一个 .c 文件中我有extern int *a.
int a[]
extern int *a
我需要知道如果我尝试访问a第二个文件中的变量会有什么行为,为什么?会出现什么问题?
a
未定义的行为。所以任何事情都可能发生。
如果两次包含文件(声明)或声明的变量名为 a,则可能会出现错误重新定义 a;
当我尝试上述编译器时显示错误:
conflicting types for a; //previous definition in other file...