> +#define CALL_COMMAND_HANDLER(name, extra...) \
> +             name(cmd_ctx, cmd, args, argc, ##extra)

That one I don't like.  It relies on lexical capture
for most parameters, and doesn't even use "name".

Lexical capture is one of the classic Things To Avoid
for C macros ... a Dirty Trick, which makes code hard
to read and evolve.  It's clearer to just pass the
params explicitly.


> +/**
> + * Always use this macro to define new command handler functions.
> + * It ensures the parameters are ordered, typed, and named properly, so
> + * they be can be used by other macros (e.g. COMMAND_PARSE_NUMBER).
> + * All command handler functions must be defined as static in scope.
> + */
> +#define COMMAND_HANDLER(name) static __COMMAND_HANDLER(name)

Why is this the only one that has a "static"?


> +/**
> + * Similar to COMMAND_HANDLER, except some parameters are expected.
> + * globally-scoped
> + */
> +#define COMMAND_HELPER(name, extra...) __COMMAND_HANDLER(name, extra)

... seems this one should have it too.
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to