C库编译错误

时间:2011-11-26 04:11:22

标签: c compiler-construction makefile compiler-errors

我正在尝试从http://www.yendor.com/programming/sort/

编译排序库

直接链接到图书馆:http://www.yendor.com/programming/sort/sort-all.tgz

当我运行 make 时,编译器说:

gcc -g -O -DCUTOFF=15 -c sorttest.c
In file included from sorttest.c:15:
sort.h:66: error: conflicting types for ‘heapsort’
/usr/include/stdlib.h:301: error: previous declaration of ‘heapsort’ was here
make: *** [sorttest.o] Error 1

有人可以帮忙解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

雾,

好吧,编译器抱怨heapsort已经在301中的行/usr/include/stdlib.h定义了......处理这些问题的传统方法是:

  • 在代码中使用其他名称作为违规文章。有人认为myheapsort应该做得很好。 (是的,你可以修改sort-all.tgz,因为它是在GNU GPL下发布的)
  • 使用#def #ifndef来抑制stdlib对heapsort的定义(如果你不能改变你的代码)。
  • 尖叫,哭泣,诅咒,并希望所有stdlib(至少)创造的地方相等。叹息。

希望有所帮助。