c/c++ bug锦集(一)

一、错误信息
warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘__time_t’ [-Wformat=]
  printf("time %u:%u\n",tv.tv_sec,tv.tv_usec);warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__suseconds_t’ [-Wformat=]
       开始的时候没有注意到错误信息最后的[-Wformat=]提醒,一直以为是类型匹配错了,把%u改成了%llu仍旧是不行。最后才注意到提醒。
然后在Ubuntu官网找到了原因:

NOTE: In Ubuntu 8.10 and later versions this option is enabled by default for C, C++, ObjC, ObjC++.  To disable, use -Wformat=0.
然后在编译的时候改成了:gcc test.c -Wformat=0 就没问题了。Wformat这个配置在Centos下默认是关闭的,所以一直没报错,如果编译的时候打开,也会提示一样的错误。


看来不同的平台,很多默认的设置还是不一样的。


Ubuntu官网的解释:http://manpages.ubuntu.com/manpages/oneiric/en/man1/gcc.1.html
 

 
 
二、错误:

dso.o:在函数‘dso_load(char const*, char const*)’中:
dso.cpp:(.text+0x3c):对‘dlopen’未定义的引用
dso.cpp:(.text+0x4c):对‘dlsym’未定义的引用
dso.cpp:(.text+0xb5):对‘dlerror’未定义的引用

dso.cpp:(.text+0x13e):对‘dlclose’未定义的引用

编译c ,如果引用了.o文件,多个.o文件吧,不能直接运行gcc demo.c -o demo,需要分步骤进行

以下是解决方案:
(在多个.o的地方运行   gcc demo1.o demo2.0 -o demo)
https://jingyan.baidu.com/article/d5a880eb8fa71d13f147cc88.html
http://blog.csdn.net/qq_29350001/article/details/53339861

我是小白,在开发科大讯飞语音唤醒的时候学习到的


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值