how to use "goto" with different file.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

how to use "goto" with different file.

3,224 次查看
eexpress
Contributor I
i had a label 'SYS_RST'; within main.c.

now want using 'goto SYS_RST' within rtc.c.

how can i define the SYS_RST in my rtc.c file. such as:
extern const *(void *) & SYS_RST;

plz help me.

for this is some special condition i must use this 'goto'. and i had search in CW's complie manual, but no answer.

if some advice, also can directlly send a message to exp.exp,gmail,com.

thanks
标签 (1)
0 项奖励
3 回复数

839 次查看
CompilerGuru
NXP Employee
NXP Employee
You cannot use the ANSI-C goto to jump across functions.
Does the ANSI-C longjmp work for your problem? Otherwise real assembly?
Maybe we can help if you let us know the problem you try to solve so we see why a normal function call does not work for your case.

Daniel
0 项奖励

839 次查看
eexpress
Contributor I
the reason is with some special conditions, my chips need partly reset. that' say just need jump to the location after CGM_Ini(). and all other steps such as initilize datas need be operated.
so i using a label called SYS_RST after CGM_Ini(). and want get the absolute address of SYS_RST. so i can directlly jump to here.

of course i can set a flag when meet the special conditions in other c file, and within my main() i judge this flag and jump to SYS_RST.

but really i want know if i can using a assembler way to do this. so if i can find how to define the label as a absolute address. i can using "asm jmp xxxxx".

thanks
0 项奖励

839 次查看
Lundin
Senior Contributor IV
longjmp() would probably work, yes.

But since that is sort of quick & dirty, perhaps you could concider a different design? Something like this perhaps:

int main()
{
init_out_of_reset();

for( ;; )
{
init_some_more();

while(everything == OK)
{
...

if(weird_error)
everything = NOT_OK;
}



}
}
0 项奖励