智能车制作

标题: CW for HC12编译环境中关于enum的疑问 [打印本页]

作者: cfistalent    时间: 2008-4-7 08:14
标题: CW for HC12编译环境中关于enum的疑问
<>最近上手CW有一段时间,问题多多,一方面是个人问题,另一方面对其了解也不够。今天碰到一个问题,希望各位高手能帮一下忙。问题如下:<BR>&nbsp; 我在一C源程序头文件中使用结构体,这个结构体内部包含一个枚举型变量的定义:<BR>typedef struct&nbsp;&nbsp;&nbsp; <BR>{<BR>byte upper_delta; <BR>enum <BR>&nbsp; {Straight_up=0,&nbsp; <BR>&nbsp;&nbsp; S_curve_up,<BR>&nbsp;&nbsp; Out_vision_up,<BR>&nbsp;&nbsp; Big_turn_up,<BR>&nbsp; }Upper_state;<BR>}UPPER_PIC_PARA;<BR>然而在程序中定义并使用这个结构体的枚举型时出现问题:<BR>UPPER_PIC_PARA pic;<BR>pic.Upper_state=Straight_up;<BR>这两句话提示Straight_up未定义。这让我很奇怪,因为如果我直接在头文件中定义一个枚举型然后在函数中使用时不会出现以上问题。 </P><P>这个问题我一直没搞清楚,请各位高手帮帮忙。谢谢了</P>
作者: superyongzhe    时间: 2008-4-21 20:18
标题: Re:CW for HC12编译环境中关于enum的疑问
没用过这种语法!
作者: whut_wj    时间: 2008-5-18 02:31
标题: Re:CW for HC12编译环境中关于enum的疑问
<>&nbsp;enum UUpper_state <BR>&nbsp; {Straight_up,&nbsp; <BR>&nbsp;&nbsp; S_curve_up,<BR>&nbsp;&nbsp; Out_vision_up,<BR>&nbsp;&nbsp; Big_turn_up<BR>&nbsp; };<BR>&nbsp;<BR>&nbsp;<BR>typedef struct&nbsp;&nbsp;&nbsp; <BR>{<BR>&nbsp; byte upper_delta; <BR>&nbsp;enum UUpper_state Upper_state;&nbsp; <BR>}<BR>UPPER_PIC_PARA;</P><P>&nbsp;</P><P>//就我理解这样写笨些,但是理解起来方便.</P>
作者: chenrunshe_007    时间: 2009-4-20 18:12
编程高手啊




欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2