首先,不需要提:最好不要用goto的忠告了,这个不是重点,我现在是要用goto的
我在main中有:
GSM:GSM_Reset();
在 timer.c中有语句:
if(voice_delayed>0)
{
voice_delayed--;
goto GSM;
}
头文件包含的顺序是也是先#include "main.h"后#include "timer.h"
编译的时候报错:
Warning[Pe177]: label "GSM" was declared but never referenced
连接的时候报错:
Error[Pe114]: label "GSM" was referenced but not defined
我定义了的,为何不还说没定义?
在IAR帮助文件中找到:
Control flow
……
Rule 14.4 (required)The goto statement shall not be used.
How the rule is checkedThe compiler will generate an error, indicating a violation of this rule, if a goto statement is used.
goto 不能用?
我这样做,
int hour=0;
while(1)
{
if( hour==1)
goto GSM;
……
if(hour==1)
{
input_fp_chck();
GSM:GSM_Reset();
}
……
hour=1;
}
编译通过,连接通过,运行OK.
什么情况? goto 不能跨文件吗? |