Paul on Nostr: TIL: A hacky but legal way to temporarily suppress a warning about an unused function ...
TIL: A hacky but legal way to temporarily suppress a warning about an unused function parameter in C is to write a statement casting it to void but not assigning the result to anything, e.g.
void parse_present(const char * const input)
{
(void) input;
}
Helpful if you're doing Test Driven Development and want to test the minimal function (e.g. returning an empty / default data structure) without writing all the code.
Works with: clang -Wall -Wextra -Werror -Wpedantic --std=c99
#C
Published at
2026-06-04 16:07:49 UTCEvent JSON
{
"id": "bd1abd3a31f1dc5991ac18917ac242a92bc73ab45ff7d7f369096accadf7239c",
"pubkey": "841863febf01dcb24f5abdb8d137ff157f77922a00fac24c2ed7a0362d48f254",
"created_at": 1780589269,
"kind": 1,
"tags": [
[
"t",
"c"
],
[
"proxy",
"https://social.xk7.net/users/pwaring/statuses/116692698376890229",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub"
]
],
"content": "TIL: A hacky but legal way to temporarily suppress a warning about an unused function parameter in C is to write a statement casting it to void but not assigning the result to anything, e.g.\n\nvoid parse_present(const char * const input)\n{\n (void) input;\n}\n\nHelpful if you're doing Test Driven Development and want to test the minimal function (e.g. returning an empty / default data structure) without writing all the code.\n\nWorks with: clang -Wall -Wextra -Werror -Wpedantic --std=c99\n\n#C",
"sig": "d5f73a76e131f95ca7de5729626b089aca42f677da55687455ad1e3fb0d86cd3094fbfc649f17303f585620e7a365c5b3319dab690f8d3d45a2bcdf0b9e23d71"
}