从兼容的指针类型传递'富'的ARG 1 [英] passing arg 1 of `foo' from incompatible pointer type

查看:151
本文介绍了从兼容的指针类型传递'富'的ARG 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这显示警告:

#include<stdio.h>
foo (const char **p)
{ 

}

int main(int argc , char **argv)
{
    foo(argv);
}

但下面不显示任何警告

But following does not show any warning

char * cp;
const char *ccp;
ccp = cp;

第一code片段显示警告通过的ARG 1从兼容的指针类型。但第二片断不显示任何警告。两者都是常量指针

The first code snippet shows warning passing arg 1 of foo from incompatible pointer type. But the second snippet does not show any warning. Both are const pointers

推荐答案

查看ç常见问题列表

您可以以去除警告投:

foo((const char **)argv);

但作为FAQ说:需要这样的投可能表明更深层次的问题而中投并没有真正解决。

But as FAQ says: the need for such a cast may indicate a deeper problem which the cast doesn't really fix.

这篇关于从兼容的指针类型传递'富'的ARG 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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