不可饶恕的GCC C ++编译器 [英] Unforgiving GCC C++ compiler
本文介绍了不可饶恕的GCC C ++编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
bool checkPointInside(const CIwVec2& globalPoint){
return checkPointIn(globalPoint ,CIwVec2());
}; ///错误:没有匹配函数调用'Fair :: Sprite :: checkPointIn(const CIwVec2&,CIwVec2)'
bool checkPointIn(const CIwVec2& globalPoint,CIwVec2& localPoint){
返回false;
};
解决方案
根据C ++标准,不能绑定右值到非const引用。但是,微软编译器有一个邪恶的扩展,允许这样做。所以g ++是正确的,不接受你的程序。
MS VS x86 compiler has no problem with the following definitions, but GCC (ARM) complains. Is GCC dumb or is MSVS_x86 too clever?
bool checkPointInside(const CIwVec2& globalPoint) {
return checkPointIn(globalPoint, CIwVec2());
}; /// error: no matching function for call to 'Fair::Sprite::checkPointIn(const CIwVec2&, CIwVec2)'
bool checkPointIn(const CIwVec2& globalPoint, CIwVec2& localPoint) {
return false;
};
解决方案
According to the C++ standard, you cannot bind an rvalue to a non-const reference. The Microsoft compiler has an evil extension that allows this, however. So g++ is correct not to accept your program.
这篇关于不可饶恕的GCC C ++编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文