conflicting types for xx错误

编译libvmi 0.8版本时,出现以下错误:
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I.. -fvisibility=hidden -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -g -O2 -MT libvmi_la-pretty_print.lo -MD -MP -MF .deps/libvmi_la-pretty_print.Tpo -c pretty_print.c  -fPIC -DPIC -o .libs/libvmi_la-pretty_print.o
pretty_print.c:31: error: conflicting types for ‘vmi_print_hex’
libvmi.h:749: note: previous declaration of ‘vmi_print_hex’ was here
make[3]: *** [libvmi_la-pretty_print.lo] Fehler 1
make[3]: Leaving directory `/usr/local/src/libvmi-0.8/libvmi'
make[2]: *** [all-recursive] Fehler 1
make[2]: Leaving directory `/usr/local/src/libvmi-0.8/libvmi'
make[1]: *** [all-recursive] Fehler 1
make[1]: Leaving directory `/usr/local/src/libvmi-0.8'
make: *** [all] Fehler 2

解决方案:

libvmi/libvmi.h:void vmi_print_hex (unsigned char *data, unsigned long length);和

libvmi/pretty_print.c:void vmi_print_hex (unsigned char *data, size_t length)
中的数据类型改为一致的即可。
 
常见此类问题的原因如下(引)

错误:
test.c:22: error: conflicting types for 'urlencode'
test.c:18: error: previous implicit declaration of 'urlencode' was here

 

原因一:
原来是因为没有先做函数声明,而函数位于main()之后。
在main函数前声明了函数原型后,一切ok.

 

原因二:

头文件的被循环引用,在引用时考虑清楚包含顺序

 

原因三:

头文件声明和定义参数稍有不同

例:

 头文件中声明 void Hanlder(const char * buf);

 在定义时写作 void Hanlder(char * buf);

这是就会发生conflicting types for 错误问题

转载于:https://www.cnblogs.com/zsw-1993/p/4879385.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值