Value: P00_THROW_CALL_RANGE_ \
(F, \
__VA_ARGS__)
Wrap a function call to F such that it throws an error on failure.
Many functions in the C and POSIX standards set errno
to ERANGE
to signal an under- or overflow. This wrapper makes this transparent such that it ensures that errno
is always checked, and if an error occurs a value is thrown.
If the error is ERANGE
the value of INT_MAX
is thrown for an overflow and INT_MIN
for a negative overflow. If the return type of F is a floating point type ERANGE
could also be set for a value that is too close to 0. In that case ERANGE
is thrown directly.
If errno
has another non-zero value that value is thrown.
- Returns
- the value of the function call if the call was successful. Never returns if it wasn't.
- See also
- P99_THROW_CALL_NEG for a similar macro that checks if the return value is negative
-
P99_THROW_CALL_VOIDP for a similar macro that checks a pointer return value
Definition at line 249 of file p99_try.h.