P99

◆ P99_THROW

#define P99_THROW (   X)    p00_jmp_throw((X), p00_unwind_top, P99_STRINGIFY(__LINE__), __func__, "throw")

Stop execution at the current point and signal an exception of value X to the next P99_TRY clause on the call stack, if any.

Remarks
If there is no such try clause on the call stack, abort is called.
Parameters
Xshould be an integer value that fits into an int.

A good convention for the values to throw is to use system wide error numbers such as ERANGE. But any other convention that fits the needs of an application can be used.

Warning
Be careful when throwing 0 as a value. This should be reserved for preliminary returns from deep recursion that is not considered being an error. In particular, throwing 0 will only unwind to the next P99_FINALLY and continue normal execution thereafter.
Utilities that change control flow in an unexpected way may result in the loss of some modifications that are effected on variables. A modern compiler should tell you when you are in such a situation. If it is the case you'd have to declare the variable in question with the volatile qualifier. For an explanation see P99_UNWIND_PROTECT.

Definition at line 120 of file p99_try.h.