linux编译中error: no arguments depend on a template parameter, declaration of * must 解决

由于标题长度的限制,只截取了关键词

比较完整的错误描述是: error: there are no arguments to '*' (这里 ‘*‘ 代表某个函数名,比如 'memset') that depend on a template parameter, so a declaration of '*' must be available

接着是错误发生位置的描述。

比如以下是在编译mldonkey这个软件的时候产生的错误描述

> src/utils/lib/CryptoPP.h:2271: error: there are no arguments to 'memset' that 

> depend on a template parameter, so a declaration of 'memset' must be available 

> src/utils/lib/CryptoPP.h:2271: error: (if you use '-fpermissive', G++ will 

> accept your code, but allowing the use of an undeclared name is deprecated)

 

这些错误是linux新版本的gcc 4.3取消了头文件多层关联造成的. 

在本例中,简单得理解错误信息是 CryptoPP.h 文件少了对memset函数的声明。实际上,memset函数是c语言函数库的基本函数,属于string.h的成员函数. 只要#include <string.h>即可。

而错误发生在这里, 主要是因为在之前的gcc版本中,只要CryptoPP.h包含的任何一个头文件里面含有#include <string.h>即可,编译器可以从当前文件包含的文件里多层地链接到c语言的string.h这个库。而现在多层链接功能失去了,于是在CryptoPP.h里用到的memset函数就成了来路不明的函数了。解决方法就是在CryptoPP.h里面加上#include <string.h>这么句话。

 

针对类似的错误,同样也是把缺失的函数声明补上。从目前的实践结果看,缺失声明的情况主要集中在几类:

http://www.cyrius.com/journal/2007/05/10#gcc-4.3-include

这个网站对这么几种情况进行了统计。

当然这个网站是用c++类库的名称表示的,如果你的程序是c,那么请相应地转换成c的库。

比如在本例中,memset 跟memcpy是属于一个库的,查询这个网站可以知道它属于c++里的cstring库,而cstring库对应于c的string.h库。

于是,这个由于gcc变化而引入的错误就解决了。


原文出处:http://geniuszhe.blog.163.com/blog/static/119346820131209171225/



------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


当然了,如果是QT5转QT4的opencv,则可尝试在所缺函数前加作用域。如:


error: there are no arguments to 'max' that depend on a template parameter, so a declaration of 'max' must be available [-fpermissive]
    RealType *tempResult = new RealType[max(rows, cols)];
                                                      ^

只需将 RealType *tempResult = new RealType[max(rows, cols)];改为

 RealType *tempResult = new RealType[cv::max(rows, cols)];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值