multiple definition of `current_cd' - oceaneys/A-CD-Record-Management-System GitHub Wiki
current_cd是全局变量,需要在main.c和methods.c中都引用到。
常规做法是,将current_cd声明在头文件data.h中,然后在main.c和methods.c中都include data.h
用如下编译命令: gcc -o exec main.c methods.c -I include -lncurses
报错:
/tmp/cc1zmLrt.o:(.bss+0x0): multiple definition of `current_cd'
/tmp/ccSktEOJ.o:(.bss+0x0): first defined here
原因:
current_cd不能定义,只能声明,即不能初始化。
修改
char current_cd[MAX_LEN] = {0}; ---> char current_cd[MAX_LEN];