c - 解决两个外部库中同名函数的类型冲突

标签 c minix

我已将以下库包含到我的代码中。

#include <minix/drivers.h>
#include <curl/curl.h>
#include <sys/stat.h>
#include <time.h>
#include <assert.h>
#include <string.h>

现在我得到以下错误:

In file included from /usr/local/include/curl/curlbuild.h:152
                 from /usr/local/include/curl/curl.h:34
                 from xxx.c:2
/usr/pkg/gcc44/lib/gcc/i686-pc-minix/4.4.3/include-fixed/sys/socket.h:134: error: conflicting types for '_send'
/usr/include/minix/ipc.h:152: note: previous declaration was here

据我所知,这意味着 _send 已在两个库中声明(minix/drivers.hcurl/curl.h),我想知道是否有可能解决这个问题或以某种方式解决它?

最佳答案

因为您使用的是 minix,您可以使用 objcopy 修改一个(或两个)库.从手册页:

--redefine-sym old=new
       Change the name of a symbol old, to new.  This can be useful when 
       one is trying link two things together for which you have no source, 
       and there are name collisions.

或者,如果您不需要来自其中一个库的_send:

-L symbolname
--localize-symbol=symbolname
       Make symbol symbolname local to the file, so that it is not visible 
       externally.  This option may be given more than once.

当然,您需要相应地更新 header 。我还建议将修改后的库和 header 命名为其他名称,以便清楚地表明您已经修改了它们。

关于c - 解决两个外部库中同名函数的类型冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8917691/

相关文章:

python - Grep 可靠地所有 C#defines

c - 关于 union 和多个整数值

c - 如何在minix中自定义proc.c来实现FCFS算法?

c - ASM/C 中的中断处理程序 - 如何? -Minix

c - 当前时间

objective-c - cgo godefs 和 Objective-C

c - 如何从X服务器读取鼠标点击事件

我可以在 C 中的数组上使用 Duff 的设备吗?

linux - 操作系统如何知道缺失页面的磁盘地址?

C - 无法编译 shmget/shmat