Define RCUTILS_CAN_FAIL_WITH

Define Documentation

RCUTILS_CAN_FAIL_WITH(failure_code)

Indicating macro similar to RCUTILS_CAN_RETURN_WITH_ERROR_OF but for use with more complicated statements.

The failure_code will be executed inside a scoped if block, so any variables declared within will not be available outside of the macro.

One example where you might need this version, is if a side-effect may occur within a function. For example, in snprintf, rcutils_snprintf needs to set both errno and return -1 on failure. This macro is used to capture both effects.

Parameters:
  • failure_code – Code that is representative of the failure case in this function.