如何跳转到最后一个调用者函数... [英] How to jump to last to last caller function...

查看:95
本文介绍了如何跳转到最后一个调用者函数...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



假设有一个函数a()将调用函数b()并且b()现在将调用c()出于某种原因我想从c()返回到a()而不通过b(). />

Hi,

Let suppose there is a function a() which will call function b() and b() will call c() now for some reason I want to return from c() to a() without going via b().

void c()
{
   /* want to return to a() from here without going via b() */
}

void b()
{
    c();
}

void a()
{
    b();
}



我们如何在c.

我们可以做些什么,比如在调用位置b()之后将地址传递一个单词然后转到该地址,但是在这种情况下,我们还没有从c()返回.

你能回答这个吗?

谢谢
vikas



How can we do it in c.

Can we do something like passing the address one word after the place b() is called and go to the address but in this case we have not returned from c().

Could you please answer this.

Thanks
vikas

推荐答案

setjmp longjmp 将完成您想做的事情.但是,最好使用返回代码将代码重组为正常返回,而不是使用非本地跳转.

不要做一些疯狂的事情,例如尝试手动跳到某个地方,因为它可能会被拧紧的栈弄得眼泪汪汪(除非您真的知道自己在做什么,否则就不会问这个问题了) .

干杯,

setjmp and longjmp will do the sort of thing you want to do. However it''s probably better to restructure your code to return normally using a return code than non-local jumping.

Don''t do something mad like trying to manually jump somewhere as it''ll probably end in tears with a screwed stack (unless you really know what you''re doing in which case you wouldn''t be asking the question).

Cheers,

Ash


这篇关于如何跳转到最后一个调用者函数...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆