如何排序的C函数? "函数previous隐式声明在这里和QUOT;错误 [英] How to sort functions in C? "previous implicit declaration of a function was here" error

查看:142
本文介绍了如何排序的C函数? "函数previous隐式声明在这里和QUOT;错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定,这已被问过,但我找不到任何可以帮助我。
我有在C函数的程序看起来像这样

I'm sure this has been asked before, but I couldn't find anything that would help me. I have a program with functions in C that looks like this

function2(){
  function1()
}
function1 (){
  function2()
}

main () {
 function1()
}

这是比这更复杂,但我使用递归。我不能安排文件中的功能,使各功能只会调用上面本身特定的功能。我不断收到一个错误

It's more complicated than that, but I'm using recursion. And I cannot arrange the function in the file so that every function would only call functions that are specified above itself. I keep getting an error

main.c:193: error: conflicting types for 'function2'
main.c:127: error: previous implicit declaration of 'function2' was here

我如何避免这种情况?感谢您事先的建议和答案。

How do I avoid this? Thanks in advance for suggestions and answers.

推荐答案

您使用前需要先声明(没有定义)至少一种功能。

You need to declare (not define) at least one function before using it.

function2();                 /* declaration */
function1() { function2(); } /* definition */
function2() { function1(); } /* definition */

int main(void) { function1(); return 0; }

这篇关于如何排序的C函数? "函数previous隐式声明在这里和QUOT;错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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