Next: , Previous: , Up: Statements   [Contents][Index]


19.14 Labels as Values

In GNU C, you can get the address of a label defined in the current function (or a local label defined in the containing function) with the unary operator ‘&&’. The value has type void *. This value is a constant and can be used wherever a constant of that type is valid. For example:

void *ptr;

ptr = &&foo;

To use these values requires a way to jump to one. This is done with the computed goto statement5, goto *exp;. For example,

goto *ptr;

Any expression of type void * is allowed.

See goto Statement and Labels.


Footnotes

(5)

The analogous feature in Fortran is called an assigned goto, but that name seems inappropriate in C, since you can do more with label addresses than store them in special label variables.