goto - Is there a way to jump to a defined by a variable in C? -
so, have program, store line number in variable, using
int x = __line__;
the value of x can keep changing. possible jump arbitrary line 1 given x, using goto or other keyword in c? i'm looking
'keyword' x;
where program shifts line defined variable x.
is there workaround if not possible?
the gcc compiler supports, extension, using labels values can work them in way resembles you're after.
it allows do:
void *ptr = &&label; label:
and then
goto *ptr;
to jump label
.
this typically useful inside core of virtual machine, , can of course lead horrible spaghetti. also, again, it's gcc extension (also supported clang, think).
Comments
Post a Comment