那天想学着老师的代码编写风格,改正自己的编码习惯,把全写main里的代码拆分成多个文件,并且在linux下用gcc编译,代码写完后,理所当然的编译不通过,哈哈哈,笑死,编译情况如下
china@ubuntu:~/1/test4$ gcc -o hhh arraylist.c arraylist_test.c
arraylist.c: In function ‘int_arraylist_init’:
arraylist.c:19:3: warning: implicit declaration of function ‘abort’ [-Wimplicit-function-declaration]
abort();
^~~~~
arraylist.c:19:3: warning: incompatible implicit declaration of built-in function ‘abort’
arraylist.c:19:3: note: include ‘<stdlib.h>’ or provide a declaration of ‘abort’
/tmp/cckjvARE.o:在函数‘int_arraylist_init’中:
arraylist_test.c:(.text+0x0): `int_arraylist_init'被多次定义
/tmp/ccQbWnay.o:arraylist.c:(.text+0x0):第一次在此定义
collect2: error: ld returned 1 exit status
而且编译的目标文件会闪一下,反正就是没有目标文件,后来,我总算学会了去爱,可惜你。。。。咳咳,回归正题,后来不打算照字照般地去网上搜问题,就准备看编译给出了什么提示,你瞧瞧我这个编译指令
gcc -o h2 arraylist.c arraylist_test.c //笑死
然后改成这样
gcc -o h2 arraylist_test.c
再次编译
china@ubuntu:~/1/test4$ gcc -o h2 arraylist_test.c
china@ubuntu:~/1/test4$ ./h2
--主函数输出--
--初始化函数输出--
china@ubuntu:~/1/test4$
//这事就是个joke,
然后就编译通过了,生成了目标文件h2,然后./h2运行也有输出语句,
然后就OK啦,拜拜