是我还是gcc? [英] Is it me or is it gcc?
问题描述
嗨
我在
linux上遇到了与gcc 3.4.6相关的奇怪模板错误。它不会发生在3.3.3或4.2.1中,所以我想知道它是否是一个
编译器错误或者编译器只是非常迂腐(但是
使用-fpermissive没有区别。)
错误是:
$ c ++ t.cc
t.cc:在成员函数`void n2< T> :: test()'':
t.cc:15:错误:`wibble''未在此范围内声明
$
代码为:
模板< typename T>
class n1
{
public:
int wibble;
};
模板< typename T>
class n2:public n1< T>
{
public:
void test()
{
wibble = 1;
}
};
int main()
{
n2< intn;
返回0;
}
它可以是固定通过改变wibble = 1到this-> wibble = 1但很明显
在每个罪恶的大型程序中执行此操作gle继承基类
变量和函数不实用。
之前有人遇到过这个并知道解决方案或者我们只是
需要转储这个版本的gcc吗?
感谢您的帮助
B2003
c ++ t.cc
t.cc:在成员函数`void n2< T> :: test()'':
t.cc:15:错误:`wibble''未在此范围内声明
代码为:
模板< typename T>
class n1
{
public:
int wibble;
};
模板< typename T>
class n2:public n1< T>
{
public:
void test()
{
wibble = 1;
}
};
int main()
{
n2< intn;
返回0;
}
可以通过更改wib来修复ble = 1到this-> wibble = 1但很明显
在一个大型程序中为每个继承的基类执行此操作
变量和函数不实用。 />
之前有人遇到过这个并且知道解决方案或者我们只是需要转发这个版本的gcc吗?
感谢您的帮助
B2003
9月12日下午12:24,Michael DOUBEZ< michael.dou。 .. @ free.frwrote:
查找与模板相关的名称: http://www.parashift.com/c++-faq-lit...html#faq-35.19
多数民众赞成只是迟钝。那个白痴想到了什么?我为什么要
" this->"在每个继承的变量和类的前面,我可能只需要
以及C中的代码!
我认为4.2.1会抛出一个错误。
也许GNU的家伙意识到这是什么PITA并取消了
支票。
B2003
hi
I''ve come across a wierd template related error with gcc 3.4.6 on
linux. It doesn''t occur with 3.3.3 or 4.2.1 so I''m wondering if its a
compiler bug or the compiler is just being extra pedantic (however
using -fpermissive makes no difference).
The error is:
$ c++ t.cc
t.cc: In member function `void n2<T>::test()'':
t.cc:15: error: `wibble'' was not declared in this scope
$
the code is:
template <typename T>
class n1
{
public:
int wibble;
};
template<typename T>
class n2: public n1<T>
{
public:
void test()
{
wibble = 1;
}
};
int main()
{
n2<intn;
return 0;
}
It can be fixed by changing wibble=1 to this->wibble=1 but clearly
doing this in a large program for every single inherited base class
variable and function is not practical.
Anyone come across this before and know the solution or do we just
need to dump this version of gcc?
Thanks for any help
B2003
c++ t.cc
t.cc: In member function `void n2<T>::test()'':
t.cc:15: error: `wibble'' was not declared in this scope
the code is:
template <typename T>
class n1
{
public:
int wibble;
};
template<typename T>
class n2: public n1<T>
{
public:
void test()
{
wibble = 1;
}
};
int main()
{
n2<intn;
return 0;
}
It can be fixed by changing wibble=1 to this->wibble=1 but clearly
doing this in a large program for every single inherited base class
variable and function is not practical.
Anyone come across this before and know the solution or do we just
need to dump this version of gcc?
Thanks for any help
B2003
On Sep 12, 12:24 pm, Michael DOUBEZ <michael.dou...@free.frwrote:Look up template-dependant name:http://www.parashift.com/c++-faq-lit...html#faq-35.19Thats just retarded. What idiot thought that up? Why would I want
"this->" in front of every inherited variable and class, I might just
as well code in C!
I thought 4.2.1 would throw an error.Perhaps the guys at GNU realise what a PITA this is and removed the
check.
B2003
这篇关于是我还是gcc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!