How to enforce parameters of anonymous blocks to be unused in Objective-C? -
i've run situation while using library called transitionkit (helps write state machines) want supply entry , exit actions in form of callback.
sadly, callbacks include 2 useless parameters. typical block has this:
^void (tkstate *state, tkstatemachine *statemachine) { // totally don't want parameters `state` or `statemachine` used here }; (this anonymous code block. read on blocks here if you're unclear)
as i've noted in comment, don't want parameters mentioned in body there. i've tried removing parameter names suggested in this question so:
^void (tkstate *, tkstatemachine *) { // foobar here }; but sadly code won't compile :(.
how can enforce non-usage of parameters in code?
this come with. quite hack , relies on gcc poison pragma, not standard gnu extension - although, given compiling clang anyway, should not problem.
#define _state state #define _statemachine statemachine #pragma gcc poison state statemachine then compiles:
^(tkstate *_state, tkstatemachine *_statemachine) { do_something(); } but doesn't:
^(tkstate *_state, tkstatemachine *_statemachine) { do_something(state, statemachine); }
Comments
Post a Comment