int fn();
void whatever()
{
(void) fn();
}
Run Code Online (Sandbox Code Playgroud)
是否有任何理由将未使用的返回值转换为无效,或者我是否认为这完全是浪费时间?
跟进:
那看起来相当全面.我认为这比评论未使用的返回值更好,因为自我记录代码比评论更好.就个人而言,我会关掉这些警告,因为这是不必要的噪音.
如果一个虫子逃脱,我会吃掉我的话......
我正在阅读一些源代码,然后出现了这个问题;
struct Cookie *
Curl_cookie_add(struct SessionHandle *data, /* rest of params were here */)
{
/* unrelated things were here */
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(void)data;
#endif
/* rest of function goes here */
}
Run Code Online (Sandbox Code Playgroud)
如您所见,void cast 指针甚至没有分配给变量。我想知道这样做的目的是什么。