功能隐式声明是无效的C99 [英] Implicit declaration of function is invalid in C99

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

问题描述

我是新来的C语言,我有,我真的不明白的一个问题。我试图从另一个函数阵列,但是当我尝试提取的信息,它给了我以下警告:


  

函数'getk_vector_calculation'隐式声明是无效的C99
  数组初始化程序必须是一个初始化列表或字符串文字


下面是code:

  INT k_vector_calculation(INT印度KREC [3]){
    ...    印度KREC [0] = L * U [0] + M * V [0] + O * [0];    印度KREC [1] = L * U [1] + M * V [1] + O * [1];    印度KREC [2] = L * U [2] + M * V [2] + O * [2];    返回k_vector_calculation(安培;印度KREC [3])}诠释的main(){    炭印度KREC [3] = getk_vector_calculation(安培;印度KREC [3]);    ...}


解决方案
的main()您调用的函数是 getk_vector_calculation()<

/ code> [这不是 k_vector_calculation()] 和这不是声明定义使用了。

要解决这个问题,


  1. 或者的#include 头文件containg 在你的SORCE文件中的声明getk_vector_calculation()。 [考虑到 getk_vector_calculation()是其他一些文件]

  2. 或添加 getk_vector_calculation()的main()并定义 getk_vector_calculation()的某个地方。

要了解更多关于隐式声明的,你可以检查此问题


编辑:

正如其他人所指出的,还有的更多的在code段的问题。但由于问题的标题仅限于隐式声明错误,海事组织,这个答案应该做要紧。剩余误差(s)是(是)一个完全不同的方面。

I am new to C language and I am having a problem that I really don't understand. I am trying to get an array from another function but when I try to extract the information, it gives me the following warning:

Implicit declaration of function 'getk_vector_calculation' is invalid in C99 Array initializer must be an initializer list or string literal

Here is the code:

int k_vector_calculation(int krec[3])

{
    ...

    krec [0] = l*u[0]+m*v[0]+o*[0] ;

    krec [1] = l*u[1]+m*v[1]+o*[1] ;

    krec [2] = l*u[2]+m*v[2]+o*[2] ;

    return k_vector_calculation( &krec[3] ) 

}

int main ()

{

    char krec[3] = getk_vector_calculation(&krec[3]); 

    ...

}

解决方案

in your main() the function you called is getk_vector_calculation() [which is not k_vector_calculation()] and which is not declared or defined before the usage.

To resolve this,

  1. either #include the header file containg the declaration of getk_vector_calculation() in your sorce file. [Considering getk_vector_calculation() is in some other file]
  2. or, add a forward declaration of getk_vector_calculation() before main() and define getk_vector_calculation() somewhere.

To know more about implicit declaration, you can check this question.


EDIT:

As others have pointed out, there are many more problems in your code snippet. But since the question title is limited to implicit declaration error, IMO, this answer should do the needful. The remaining error(s) is(are) altogether a different aspect.

这篇关于功能隐式声明是无效的C99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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