简体   繁体   中英

C instruction address

Disclaimer, I not do anything in particular with regards this question, just curious.

Is it possible to take address of instruction or block in C? in essence, is there jump equivalent in C?

for example:

void function() {
    int k;
    { // is a possible to go to this address from arbitrary point in code?
      int i, j;
      k += j+i;
    }
}

thank you

Yes, use goto :

void function() {
    int k;
    { // is a possible to go to this address from arbitrary point in code?
myLabel:
      int i, j;
      k += j+i;
    }

// stuff

    goto myLabel;
}

I think the closest you can come using standard techniques is setjmp and longjump . They won't get you access to the actual address though, because the jmp_buf object is opaque.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM