网上移植的单片机菜单程序,拿过来用的时候编译报错,本人对这种结构不是很熟悉,请指教一下
typedef struct
{
uchar CurrentIndex; //当前功能索引号
uchar UpKeyIndex; //按下上键时的功能索引号
uchar DownKeyIndex; //按下下键时的功能索引号
uchar SetKeyIndex; //按下设置键时的功能索引号
uchar OkKeyIndex; //按下确定键时的功能索引号
void (*CurrentFunction)(); //当前执行的功能
} KeyIndex;
KeyIndex code IndexTab[8]=
{
{0,3,1,0,4,(*Function0)},
{1,0,2,0,5,(*Function1)},
{2,1,3,0,6,(*Function2)},
{3,2,0,0,7,(*Function3)},
{4,0,0,0,0,(*Function4)},
{5,0,0,0,0,(*Function5)},
{6,0,0,0,0,(*Function6)},
{7,0,0,0,0,(*Function7)},
};
void Key_response(void)
{
if(UpKeyPress==0)
{
UpKeyPress=1;//Clear_Screen();//查找按上键对应的功能索引
KeyFunctionIndex=IndexTab[KeyFunctionIndex].UpKeyIndex;
}
if(DownKeyPress==0)
{
DownKeyPress=1;//Clear_Screen();
KeyFunctionIndex=IndexTab[KeyFunctionIndex].DownKeyIndex;
}
if(OkKeyPress==0)
{
OkKeyPress=1;//Clear_Screen();
KeyFunctionIndex=IndexTab[KeyFunctionIndex].OkKeyIndex;
}
if(SetKeyPress==0)
{
SetKeyPress=1;//Clear_Screen();
KeyFunctionIndex=IndexTab[KeyFunctionIndex].SetKeyIndex;
}
KeyFunctionPtr=IndexTab[KeyFunctionIndex].CurrentFunction;
(*KeyFunctionPtr)(); //根据功能索引,执行当前功能
}
Error[Pe065]: expected a ";" C:\Users\chenweijian\Desktop\menu\menu.c 17
Warning[Pe012]: parsing restarts here after previous syntax error C:\Users\chenweijian\Desktop\menu\menu.c 27
Error[Pe020]: identifier "IndexTab" is undefined C:\Users\chenweijian\Desktop\menu\menu.c 35
Error[Pe020]: identifier "IndexTab" is undefined C:\Users\chenweijian\Desktop\menu\menu.c 40
Error[Pe020]: identifier "IndexTab" is undefined C:\Users\chenweijian\Desktop\menu\menu.c 45
Error[Pe020]: identifier "IndexTab" is undefined C:\Users\chenweijian\Desktop\menu\menu.c 50
Error[Pe020]: identifier "IndexTab" is undefined C:\Users\chenweijian\Desktop\menu\menu.c 52
KeyIndex code IndexTab[8]=
试试改为
code KeyIndex IndexTab[8]=
怀疑是这里写错了,导致IndexTab定义失败,所以后面报错说IndexTab没有定义。
最好贴完整文件,这样才好把行号和错误对应上,否则不好分析