【问题标题】:C Library Compile ErrorC 库编译错误
【发布时间】:2011-11-26 04:11:21
【问题描述】:

我正在尝试从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

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

【问题讨论】:

  • 看起来有两个文件试图定义heapsort

标签: c compiler-construction makefile compiler-errors


【解决方案1】:

冷冰冰的,

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

  • 在您的代码中为有问题的文章使用另一个名称。有人认为myheapsort 应该做得很好。 (是的,您可以修改 sort-all.tgz,因为它是在 GNU GPL 下发布的)
  • 使用#def #ifndef 抑制stdlib 对heapsort 的定义(如果您无法更改代码)。
  • 尖叫,哭泣,诅咒,并希望所有stdlibs(至少)生而平等。叹息。

希望对您有所帮助。

【讨论】:

  • 谢谢!我采纳了您的建议,只是将代码更改为 myheapsort。
猜你喜欢
  • 1970-01-01
  • 2016-03-24
  • 1970-01-01
  • 2015-08-08
  • 1970-01-01
  • 2015-12-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多