功能隐式声明是无效的C99 [英] Implicit declaration of function is invalid in 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()
] 和这不是声明
或定义
使用了。要解决这个问题,
- 或者
的#include
头文件containg在你的SORCE文件中的声明getk_vector_calculation()
。 [考虑到getk_vector_calculation()
是其他一些文件]- 或添加
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 isgetk_vector_calculation()
[which is notk_vector_calculation()
] and which is notdeclared
ordefined
before the usage.To resolve this,
- either
#include
the header file containg the declaration ofgetk_vector_calculation()
in your sorce file. [Consideringgetk_vector_calculation()
is in some other file]- or, add a forward declaration of
getk_vector_calculation()
beforemain()
and definegetk_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屋!