为什么要投一个未使用的函数参数值无效? [英] Why cast an unused function parameter value to void?

查看:121
本文介绍了为什么要投一个未使用的函数参数值无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一些项目中,我看到了这个code:

In some project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
    (void)ud;
    (void)osize;
    /* some code not using `ud` or `osize` */
    return ptr;
}

因为这两种类型转换为void任何目的?

Do the two casts to void serve any purpose?

推荐答案

它的存在,以避免编译器警告,因为有些参数未使用。

It is there to avoid warnings from the compiler because some parameters are unused.

这篇关于为什么要投一个未使用的函数参数值无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆