可能重复使用:
What is the purpose of the statement “(void)c;”?是什么`(无效)的D'
class ArgString : public Arg::Base
{
public:
...
bool CanConvertToInt() const
{
const char *cstr = mValue.c_str();
char *result = 0;
long d = strtol(cstr, &result, 10);
(void) d; // what is the usage of this line?
return result != cstr;
}
private:
std::string mValue;
};
谁能告诉我下面的行的目的是什么?
(void) d;
谢谢
// //更新
正如一些人指出,该行的目的是抑制编译警告。对我来说,这很奇怪。因为这是非常严重的警告
warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use
_CRT_SECURE_NO_WARNINGS. See online help for details.
为什么我们忽略这个大的警告,并只处理较小的警告。
我不知道目的是什么,但它恕我直言,声明不产生任何效果;-) – emesx 2011-12-13 16:59:05
请注意,这是你有控制权的代码,请评论答案后。 – 111111 2011-12-13 16:59:35