gcc 后出现的error和warming 修改(更新中)

36 篇文章 1 订阅
22 篇文章 0 订阅

1. error:expected primary-expression before 'unsigned'

有可能是 unsigned 前面的 符号 是全角型,而不是 半角型。

2.  error: invalid conversion from ‘const void*’ to ‘void*’

由于gcc版本较高,类型检查较为严格,这边是 字符串的问题,比如

pthread_cleanup_push(cleanup, "thread 1 first handler");   "thread 1 first handler"前 需要添加 (void *) 进行类型强制转换

3. error: invalid conversion from ‘void*’ to ‘foo*’

源代码:

if ((fp = malloc(sizeof(struct foo))) != NULL)

添加修改后如下:

    if ((fp = (struct foo*)malloc(sizeof(struct foo))) != NULL)

4.

main.cpp:9: error: expected template-name before ‘<’ token
main.cpp:9: error: expected ‘{’ before ‘<’ token
main.cpp:9: error: expected unqualified-id before '<' token

这个是头文件引用不当引起或者使用某个容器,却没包含这个容器的头文件

比如 使用了list容器,就应该写 #include <list>


5.main.cpp: In function ‘int main()’:
main.cpp:43: error: expected unqualified-id before ‘.’ token
main.cpp:44: error: expected unqualified-id before ‘-id beforV

使用typedef 自定义了一个类型名,而在下面引用的时候把类型名当做变量直接使用


main.cpp: In member function ‘typename std::list<T, std::allocator<_CharT> >::iterator MyList<T>::find(const T&) [with T = PicBuffer*]’:
main.cpp:77:   instantiated from here
main.cpp:39: error: no matching function for call to ‘find(std::_List_iterator<PicBuffer*>, std::_List_iterator<PicBuffer*>, PicBuffer* cons { T cTB

6、 >  >不能写成 >>紧挨在一起

typedef MyList<std::vector<int> > ListVector;


7、linux编译中error: no arguments depend on a template parameter, declaration of * must 解决 http://hi.baidu.com/laoliang1984/item/6b1066bf82a27040ba0e12e1


8、warning: -fPIC ignored for target (all code is position independent)
-fpic:产生位置无关码
解释一下,位置无关码就是可以在进程的任意内存位置执行的目标码,动态链接必须使用。

其中dlfch.h是一个调用动态链接库用的头文件。


9 、main.cpp:5: error: expected unqualified-id before ‘template’

关键字 template不能作为变量名。

10、

tar: root_qtopia/usr/sbin/telnetd:无法创建到 “../../bin/busybox” 的符号连接: 操作不允许


tar: root_qtopia/usr/sbin/fbset:无法创建到 “../../bin/busybox” 的符号连接: 操作不允许
tar: 由于前面延迟的错误而退出

原因:不能使用tar命令在window分区下解压文件夹


11、

/usr/bin/ld: cannot find -lxxx问题总结
linux下编译应用程序常常会出现如下错误:
/usr/bin/ld: cannot find -lxxx
 意思是编译过程找不到对应库文件。其中,-lxxx表示链接库文件 libxxx.so。

12、
main.c|62| warning: passing argument 2 of ‘lh_doall_arg’ from incompatible pointer type
将第二个参数添加(void *)进行强制转换,即可消除告警

13、
 invalid conversion from ‘void (*)()’ to ‘void (*)(int)’
函数参数个数或者类型不对应
#include <stdio.h>
#include <signal.h>
void signal_handler()
{
    printf("hello, world!\n");
    //alarm(1);
}
int main()
{
    signal(SIGINT, signal_handler);
    while(1)
    {
    }
    return 0;
}

void signal_handler()
写成 void signal_handler(int signum); 即可编译通过。




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值