Why cast unused return values to void?

后端 未结 9 1361
暗喜
暗喜 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:39

    Also when verifying your code complies to MISTA (or other) standards, automatic tools such as LDRA will not allow you to call a function that has a return type without having it return a value unless you explicitly cast the returned value to (void)

提交回复
热议问题