Whole document tree
4.3 Labels as Values
You can get the address of a label defined in the current function
(or a containing function) with the unary operator `&&'. The
value has type
To use these values, you need to be able to jump to one. This is done
with the computed goto statement(1),
Any expression of type One way of using these constants is in initializing a static array that will serve as a jump table:
Then you can select a label with indexing, like this:
Note that this does not check whether the subscript is in bounds--array indexing in C never does that.
Such an array of label values serves a purpose much like that of the
Another use of label values is in an interpreter for threaded code. The labels within the interpreter function can be stored in the threaded code for super-fast dispatching. You can 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. This document was generated by root on January, 30 2002 using texi2html |