【发布时间】:2013-04-04 11:48:51
【问题描述】:
关注我之前的question:
现在我有了这个:
xml_list *text1(xml_list *);
xml_list *text(xml_list *);
//operation: text1(elem)
xml_list *text1(xml_list *elem){
if(isText(elem)){
return Cons(elem,Nil());
}
else{
return text(childeren(elem));
}
}
//operation: text(elem)
xml_list *text(xml_list *elem){
if(isEmpty(elem)){
return Nil();
}
return append(text1(head(elem)),text(tail(elem)));
}
当我运行它时,我会收到 xml_list *text1 的警告:
incompatible pointer types passing 'xml_list *' (aka 'struct xml_list_struct *') to parameter of type 'xml *' (aka 'struct xml_struct *') [-Wincompatible-pointer-types]
if(isText(elem)){
还有下一行的警告:
warning: incompatible pointer types passing 'xml_list *' (aka 'struct xml_list_struct *') to parameter of type 'xml *' (aka 'struct xml_struct *') [-Wincompatible-pointer-types]
return Cons(elem,Nil());
再次警告:
warning: incompatible pointer types passing 'xml_list *' (aka 'struct xml_list_struct *') to parameter of type 'xml *' (aka 'struct xml_struct *') [-Wincompatible-pointer-types]
return text(children(elem));
我怎样才能让这些警告消失??
【问题讨论】:
-
那么,
isEmpty()、Cons()和children() 的原型是什么?它们显然与您传递的论点不相容。你需要解决这个问题。 -
isEmpty(xml_list *elems) 及其返回 int。 Cons(xml *hd, xml_list *tl) 它返回 xml_list。 children(xml *elem) 并返回 xml_list。