[neomutt-devel] Unused parameters
Richard Russon
rich at flatcap.org
Thu Nov 23 14:17:04 CET 2017
We've eliminated quite a few unused parameters in function prototypes,
but there are many more left. Mostly they're where we've defined an
API, such as the format strings.
gcc and clang provide: `__attribute__((__unused__))`
How do people feel about marking these unused parameters?
e.g.
#define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
This macro has two properties:
- The attribute tells the compiler that the variable is unused
- It renames the variable to avoid it *being* used
static const char *cb_format_str(char *dest, size_t destlen, size_t UNUSED(col),
int UNUSED(cols), char op, const char *src,
const char *UNUSED(prefix),
const char *ifstring, const char *elsestring,
unsigned long data, enum FormatFlag flags)
This *does* add visual clutter to the code, but it can be hidden with a
vim conceal. This script hides the `UNUSED()` part completely, but adds
a red dagger (†) as a suffix.
syntax region U_surround matchgroup=U_variable start="UNUSED(" skip="\i\+" end=")" concealends cchar=†
highlight U_surround ctermfg=none guifg=NONE
highlight U_variable ctermfg=red guifg=red
What do you think?
Rich / FlatCap
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20171123/a18cbffa/attachment.sig>
More information about the neomutt-devel
mailing list