4 ms·
>It is sinful to jump into a different function So sinful you can't in C
by wcummings 12y ago
>It is sinful to jump into a different function
So sinful you can't in C
- danudey 12y agoI assumed the parent poster meant back before functionality was expressed as functions; i.e. it's sinful to jump from functionality A to functionality B if it's not expressed in terms of packaged functions, and impossible to do so if it is.
- astrange 12y agoYou can do it in GNU C! It's used to write direct-threading interpreters. https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Labels-as-Values.html https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Labels-as-Values....
- knome 12y agoThey don't intend for label addresses to be gone to outside of the function they are located in. The stack wouldn't be setup to handle them at all. Sure, you can store them wherever, and do something like " goto *g_greenthreads[ threadno ].lastpos ", but you would call that within the function defining the label, not outside it. From your own link: > You may not use this mechanism to jump to code in a different function. If you do that, totally unpredictable things will happen. The best way to avoid this is to store the label address only in automatic variables and never pass it as an argument.
- tormeh 12y agoWith longjmp you can. Your stack will be trashed, though, so any state better be global!