Skip to content

UNUSED

Description

Mark x as deliberately unused at this point. Expands to the canonical (void)(x) cast – works on every C compiler (no __attribute__ / __pragma dispatch needed). Use it to silence -Wunused-variable / -Wunused-parameter on a name that the surrounding code legitimately doesn’t touch, and to mark a scope-default like MisraScope as “read” when the body never references it.

Usage example (from documentation)

  void cb(int reason, void *ctx) {
      UNUSED(reason);
      UNUSED(ctx);
      ...
  }

Usage example (Cross-references)

Usage examples (Cross-references)
                           *MisraScope       = &UNPL(scope_internal).base,                                                 \
                           *UNPL(scope_done) = name;                                                                       \
                 (UNUSED(MisraScope), UNPL(scope_done));                                                                   \
                 UNPL(scope_done) = NULL)
    #define ScopeWith(alloc_ptr)                                                                                           \
        for (Allocator *MisraScope = (alloc_ptr), *UNPL(scope_with_done) = MisraScope;                                     \
             (UNUSED(MisraScope), UNPL(scope_with_done));                                                                  \
             UNPL(scope_with_done) = NULL)
Last updated on