C警告冲突的类型 [英] C warning conflicting types

查看:126
本文介绍了C警告冲突的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是

void doc(){
          //mycode                
            return;
           }

我警告

conflicting types for 'doc'

有谁能够解决这个问题。

can anybody solve it.

推荐答案

在C,如果你没有一个原型功能,当你调用它,它被假设为返回 INT ,并采取参数数目不详。然后,当你以后定义函数为返回无效,并采取任何参数,编译器认为这是一个矛盾。

In C, if you don't have a prototype for a function when you call it, it is assumed to return an int and to take an unspecified number of parameters. Then, when you later define your function as returning void and taking no parameters, the compiler sees this as a conflict.

取决于您的code的复杂性,你可以做其使用前将函数的定义一样简单的东西,或者在头文件中添加函数的声明的,包括它

Depending upon the complexity of your code, you can do something as simple as moving the definition of the function before its use, or add the function declaration in a header file and include it.

在任何情况下,净效应应该是使函数原型可被使用之前,它

In any case, the net effect should be to make the function prototype available before it is being used.

如果您添加

void doc(void);

功能在使用前,将在域中可见的原型,你的警告将消失。

before the function use, you will have a prototype visible in scope, and your warning will go away.

我觉得这是对你的警告是最有可能的原因。你可以有商务部的明确声明不兼容在code,但我们不能说,因为你还没有公布完整的code。

I think this is the most likely cause for your warning. You could have an explicit incompatible declaration of doc in your code, but we can't tell because you have not posted complete code.

这篇关于C警告冲突的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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