1.编译:
可能会有以下编译错误:
../include/zthread/Guard.h: In destructor 'ZThread::Guard::~Guard()':
../include/zthread/Guard.h:494: error: there are no arguments to 'isDisabled' that depend on a template parameter, so a declaration of 'isDisabled' must be available
../include/zthread/Guard.h:494: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
make[3]: *** [AtomicCount.lo] 错误 1
|
节选自:
http://blog.sina.com.cn/s/blog_591f0e6e010008o7.html
实际上解决方法编译结果已经说了.
一种是使用-fpermissive开关来允许老的语法,
用export CXXFLAGS=-fpermissive,然后在configure
另一种方法可以在调用函数时加this.
this->isDisabled()
还可以把isDisabled()在那个类头部分重新声明一下.
using BaseClass::isDisabled();
简单而言,对应g++3.4以后版本的名字查找方法,模板类中对基类方法或者基类的成员变量的调用,如果该基类方法或者基类成员变量与模板参数类型(typename
T)无关,则需要使用this-> 调用或者在类定义中声明using
BaseClass::function();
编译不过的核心解释:
阅读(1848) | 评论(2) | 转发(0) |