|
nros C API
Lightweight ROS 2 client for embedded real-time systems
|
Error-check convenience macros for the nros C API. More...
#include "rclc/types.h"

Go to the source code of this file.
Macros | |
| #define | RCLC_CHECK(call) |
| #define | RCLC_CHECK_LOG(file, line, expr, ret) ((void)(file), (void)(line), (void)(expr), (void)(ret)) |
| #define | RCLC_CHECK_RET(call, retval) |
| #define | RCLC_SOFTCHECK(call) |
Error-check convenience macros for the nros C API.
Wraps the common "call returns rcl_ret_t; on failure log and bail" pattern in one-liners so example main()s and user code don't open-code 4-line check blocks at every API site.
Pattern parity with rclc:
RCLC_CHECK(call) — fatal: log and return from the enclosing void function.RCLC_SOFTCHECK(call) — non-fatal: log and continue.The macros log file:line, the literal call text, and the integer return code. Issue 0332 — the default logger is printf ONLY on a hosted target (__STDC_HOSTED__) or when RCLC_CHECK_STDIO is defined; on a freestanding embedded target it defaults to a no-op, so a no_std C node does not silently pull <stdio.h> into every TU.
Override the log function by defining RCLC_CHECK_LOG(file, line, expr,
ret) before including this header (e.g. to route through a board's UART, RTT, or nros-log), or define RCLC_CHECK_STDIO to force the printf form on a freestanding target.
Copyright 2026 nros contributors Licensed under Apache-2.0
| #define RCLC_CHECK | ( | call | ) |
Fatal check: evaluate call once; if the returned rcl_ret_t is not RCL_RET_OK, log the failure and return from the enclosing function (which must return void or accept a bare return;).
| #define RCLC_CHECK_LOG | ( | file, | |
| line, | |||
| expr, | |||
| ret | |||
| ) | ((void)(file), (void)(line), (void)(expr), (void)(ret)) |
| #define RCLC_CHECK_RET | ( | call, | |
| retval | |||
| ) |
Like RCLC_CHECK but for callers that need a custom return value (non-void functions). Returns retval on failure.
| #define RCLC_SOFTCHECK | ( | call | ) |
Non-fatal check: evaluate call once; on failure, log and continue. Use for "best effort" calls (e.g. publishing a heartbeat) where one dropped iteration shouldn't tear down the node.