Why cast unused return values to void?

后端 未结 9 1359
暗喜
暗喜 2020-11-22 09:00
int fn();

void whatever()
{
    (void) fn();
}

Is there any reason for casting an unused return value to void, or am I right in thinking it\'s a c

9条回答
  •  执念已碎
    2020-11-22 09:56

    Cast to void is costless. It is only information for compiler how to treat it.

提交回复
热议问题