【发布时间】:2014-09-19 17:18:18
【问题描述】:
经过相当长的调试时间后,我发现我的代码中有一个错误,归结为这样的事情,我感到很愚蠢:
int main()
{
double p1[] = { 1, 2, 3 };
double p2[] = { 1, 2, 3 };
int color = 1;
bool some_condition = true;
if (some_condition) (p1, p2, color);
}
(p1, p2, color) 表达式的计算结果是它的最后一个操作数,但是编译器应该以某种方式保护我吗? (Visual Studio 什么也没说)
是的,你猜对了,我想调用一个绘图函数:Draw(p1, p2, color)
【问题讨论】:
-
我希望收到未使用的警告。
-
@chris 这是我从 clang 中得到的。来自 g++ 的
-Wall. -
@JosephMansfield,确实如此。它甚至是三个警告,所以它真的很吸引你的眼球。
-
然而,Visual Studio 不会抱怨,即使是 /Wall
-
@NikosAthanasiou 这是关于未使用表达式结果的警告,而不是变量。
标签: c++ debugging warnings comma-operator