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

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

问题描述

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

My compiler (GCC) is giving me the warning:

警告:函数的隐式声明

请帮助我理解为什么会出现这种情况.

Please help me understand why is it coming.

推荐答案

您正在使用编译器尚未看到其声明(prototype")的函数.

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)
{
    /* ... */
}

你需要在 main 之前声明你的函数,就像这样,直接或在标题中:

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天全站免登陆