xxxxxxxxxx
import std.stdio;
import core.sys.posix.setjmp;
enum JumpTarget {normal = 0, GOTO_LABEL_EXTRA1, GOTO_LABEL_EXTRA2}
jmp_buf backToMain;
void main()
{
int res = setjmp(backToMain);
with (JumpTarget) final switch (res) {
case normal:
someFunction1();
break;
case GOTO_LABEL_EXTRA1:
writeln("extra 1");
break;
case GOTO_LABEL_EXTRA2:
writeln("extra 2");
break;
}
}
void someFunction1() {
someFunction2();
assert(0); // uh oh, someFunction2 better not return
}
void someFunction2() {
longjmp(backToMain, JumpTarget.GOTO_LABEL_EXTRA2);
assert(0);
}