【发布时间】:2014-02-24 06:18:25
【问题描述】:
这是我的代码库的一部分
代码:
bool succ = true;
//below is the place where warning is there
succ &= draw( e0.x, e0.y, e0.z, (e0.x + dir.x), (e0.y + dir.y), (e0.z + dir.z));
//------
//------
bool draw( FLOAT x, FLOAT y, FLOAT z, FLOAT p, FLOAT q, FLOAT r)
{
bool ret;
ret = fun(x,y,z,p,q,r);
return ret;
}
警告:
Warning 514: Unusual use of a Boolean expression
Info 1786: Implicit conversion to Boolean (assignment) (int to bool)
我不想增加代码行,所以在一行中执行此逻辑...有人可以帮助我解决此问题...
【问题讨论】:
-
succ = succ && draw(...)?如果你有很多这样的调用,可能值得为它编写一个简单的实用函数 -
draw 正在返回 bool ....所以只需将结果与 succ 相加并将结果存储在 succ 中
-
@auselen 我猜他在同一个函数中有一堆绘图调用,并想检查是否全部成功
-
当 draw() 是一个只做一行工作的三行函数并且可能根本不需要时,为什么要如此关注使 succ 分配保持在一行?跨度>
-
@Daniel 确实有很多draw call