警告:函数隐式声明 [英] warning: implicit declaration of function

查看:232
本文介绍了警告:函数隐式声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的编译器(GCC)是给我警告:

My compiler (GCC) is giving me the warning:

警告:函数隐式声明

请帮助我了解为什么它的到来。

Please help me understand why is it coming.

推荐答案

您正在使用该编译器还没有见过一个声明(原型的),但功能。

You are using a function for which the compiler has not seen a declaration ("prototype") yet.

例如:

int main()
{
    fun(2, "21"); /* The compiler has not seen the declaration. */       
    return 0;
}

int fun(int x, char *p)
{
    /* ... */
}

您需要之前的主声明你的功能,这样,无论是直接或头:

You need to declare your function before main, like this, either directly or in a header:

int fun(int x, char *p);

这篇关于警告:函数隐式声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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