2011-11-26 119 views
1

我试图从http://www.yendor.com/programming/sort/C库编译错误

直接链接编译整理库库:http://www.yendor.com/programming/sort/sort-all.tgz

当我运行使编译器说:

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 

灿有人帮助解决这个问题?

+0

看起来像两个文件试图定义'heapsort' – tekknolagi

回答

2

雾,

那么,编译器抱怨型heapsort在行301/usr/include/stdlib.h已经定义...对于解决这些问题的传统方法是:

  • 使用其他名称对于代码中的违规文章。一个假设myheapsort应该做得很好。 (是的,你可以修改sort-all.tgz,怎么把它基于GNU GPL发布)使用#def的#ifndef(如果你不能改变你的代码)的heapsort
  • 剿STDLIB的定义。
  • 尖叫,哭泣,诅咒,并希望所有stdlib(至少)在哪里创建的平等。叹。

希望有帮助。

+0

谢谢!,我用你的建议,只是改变了代码myheapsort。 – Icestorm