我编了一个有头循环单链表,然后分成三个文件,分别是头文件(slist.h),测试文件(test.c),函数文件(slist.c)。一个文件用gcc编译没问题,但是分开后就出现
root@ubuntu:/home/uplooking/slist_head_loop# gcc -o slist.c test.c
/tmp/ccUOAE3w.o: In function `main':
test.c:(.text+0x2f): undefined reference to `init_head'
test.c:(.text+0x4d): undefined reference to `list_add'
test.c:(.text+0x61): undefined reference to `list_add_tail'
test.c:(.text+0x81): undefined reference to `list_del'
test.c:(.text+0x95): undefined reference to `list_for_each'
collect2: ld returned 1 exit status
请问是什么问题,.c文件都包含了所需要的头文件。而且编译几次后,slist.c文件就莫名其妙的没了,很纠结!
还是不行额,好多warning, 说是指针类型不兼容...
本回答被提问者采纳