P99

◆ P99_THROW_CALL_NEGATE

#define P99_THROW_CALL_NEGATE (   F,
  E,
  ... 
)    P00_THROW_CALL_NEGATE(F, E, __VA_ARGS__)

Wrap a function call to F such that it throws an error on negative return.

A common strategy of libraries and also the Linux kernel is to return an int and signal an error with a negative value. The error code is then the negation of that return value. This wrapper makes this transparent such that it ensures that the error code is always checked, and if an error occurs the negated value is thrown.

Returns
the value of the call to the function if that was successful. Never returns if it wasn't.
See also
P99_THROW_CALL_NEG for a similar macro that also checks if the return value is negative but that returns the value of errno, instead.
P99_THROW_CALL_ZERO for a similar macro that checks if the return value is 0
P99_THROW_CALL_VOIDP for a similar macro that checks a pointer return value

Definition at line 449 of file p99_try.h.