C 库编译错误

发布于 2024-12-18 14:12:51 字数 593 浏览 0 评论 0原文

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

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

I'm trying to compile the sorting library from http://www.yendor.com/programming/sort/

Direct Link to library: http://www.yendor.com/programming/sort/sort-all.tgz

When I run make the compiler says:

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

Can someone help with this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾听心声的旋律 2024-12-25 14:12:51

Frosty,

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

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

希望有帮助。

Frosty,

Well, the compiler is complaining that the type heapsort is already defined at line 301 in /usr/include/stdlib.h ... the traditional methods for dealing with these issues are :

  • Use another name for the offending article in your code. One supposes that myheapsort should do nicely. (and yes you can modify sort-all.tgz, coz it's published under GNU GPL)
  • supress stdlib's definition of heapsort using #def #ifndef (if you can't change your code).
  • Scream, cry, curse, and wish that all stdlibs (at least) where created equal. Sigh.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文