我正在检查代码,我遇到了以下代码段:
int check(char *a)
{
(void)(a);//What is this line doing??
return 0;
}
int main(void)
{
char *p;
p=(char *)malloc(sizeof(char));
check(p);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在(void)(a);做什么?
如果函数中没有使用函数参数,某些编译器可能会发出警告,(void)a可以使这些警告静音.
实现这一目标的另一个方法是:
int check(char *a)
{
a = a;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1447 次 |
| 最近记录: |