Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519915
  • 博文数量: 137
  • 博客积分: 3170
  • 博客等级: 中校
  • 技术积分: 1455
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-17 11:47
文章分类

全部博文(137)

文章存档

2015年(2)

2013年(1)

2012年(6)

2011年(5)

2010年(62)

2009年(61)

我的朋友

分类: C/C++

2011-02-14 17:50:00

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();
编译不过的核心解释:

阅读(1793) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-06 17:49:20

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com

chinaunix网友2011-03-06 17:48:59

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com