什么是无效铸造吗? [英] What does void casting do?

查看:182
本文介绍了什么是无效铸造吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一些源$ C ​​$ C,这上来;

I was reading some source code, and this came up;

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 */
}

正如你所看到的,无效的指针铸造,甚至没有分配给一个变​​量。我想知道什么是这样做的目的。

As you can see, void casted pointer, isn't even assigned to a variable. I was wondering what is the purpose of this.

推荐答案

本投燮presses,如果不使用数据将出现一个编译器警告。

This cast suppresses a compiler warning that would arise if data is not used.

GCC所产生的这个警告,如果 -Wunused参数标志(由 -Wextra 暗示)已启用。

GCC produces this warning if the -Wunused-parameter flag (implied by -Wextra) is enabled.

这篇关于什么是无效铸造吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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