typedef struct people { char name [TEL]; char tel [TEL]; char address[TEL]; char relation[TEL]; struct people * pst; }List; List * Ns; List * Head; List * Next;
int innew (char s[]); int show (List * read,int num);
error LNK2005: "struct people * Head" (?Head@@3PAUpeople@@A) 已经在 hus_coole.obj 中定义 error LNK2005: "struct people * Ns" (?Ns@@3PAUpeople@@A) 已经在 hus_coole.obj 中定义 error LNK2005: "struct people * Next" (?Next@@3PAUpeople@@A) 已经在 hus_coole.obj 中定义
就是这三个结构指针的重定义错误,一个头俩个大 急求帮忙(运行环境VS2010) C Visual?Studio?2010 重定义 ADT [解决办法] 头文件
extern List * Ns; extern List * Head; extern List * Next;
main.c
List * Ns; List * Head; List * Next;
[解决办法] 不要在头文件中定义变量和函数实体,这些都要放在.c中进行,头文件只是导出变量和函数符号而已,比如: extern List * Ns;
extern List * Head; extern List * Next; 函数符号的导出加不加extern都是可以的: extern int innew (char s[]); int innew (char s[]);
在hus_coole.c中定义 List * Ns; List * Head; List * Next; 在hus_coole.h中声明为外部变量 extern List * Ns; extern List * Head; extern List * Next; 这样就可以了,否则你原来那样三个变量既在hus_coole.c中定义又在main.c中定义