错误:冲突的类型 [英] Error: conflicting types
本文介绍了错误:冲突的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写code C语言为一项任务。
I am writing code in C for an assignment.
这是有关code:
//operation: text(elem)
xml_list *text(xml_list *elem){
if(isEmpty(elem)){
return Nil();
}
return append(text1(head(elem)),text(tail(elem)));
}
//operation: text1(elem)
xml_list *text1(xml_list *elem){
if(isText(elem)){
return Cons(elem,Nil());
}
else{
return text(childeren(elem));
}
}
这给我的错误:错误:冲突的类型'文本1'
xml_list *文本1(xml_list * ELEM){
我无法找出问题的根源。我一直在这8小时直,现在,我有点失去理智了这一点。请有人帮助我
I can't figure out the source of the problem. I have been working on this for 8 hours straight now, and I am kind of losing my mind over this. Please some one help me
推荐答案
按到达时间
return append(text1(head(elem)),text(tail(elem)));
编译器不知道文本1
的返回类型。因此,它假定 INT
并记住它。后来当它到达文本1的定义,这将是相互矛盾的。
The compiler doesn't know the return type of text1
. So it assumes int
and remembers it. And later when it reaches the definition of text1 it will be conflicting.
要解决这个前锋text1的声明像
To solve this forward declare text1 like
xml_list *text1(xml_list *); // <---- Here
xml_list *text(xml_list *elem){
if(isEmpty(elem)){
return Nil();
}
return append(text1(head(elem)),text(tail(elem)));
}
//operation: text1(elem)
xml_list *text1(xml_list *elem){
if(isText(elem)){
return Cons(elem,Nil());
}
else{
return text(childeren(elem));
}
}
这篇关于错误:冲突的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文