Re:Android Project Changeset 4f8b683: libc/memset.c
by humbledrone on Tuesday May 25, 2010 @08:58PM
(#1379197)
It's not hard to type a statement like "(void)v;" to explicitly say, "v is intentionally unused." I fail to see the drawback of this approach. Of course you should only do this when (1) you can't remove the parameter from the function's prototype and (2) there is a good reason for it to be unused. But once you develop that habit, the compiler can help you catch bugs that are otherwise easy to miss. Sounds like a worthwhile tradeoff to me.
[ Parent
| on HN ]
Re:Android Project Changeset 4f8b683: libc/memset.c
by leif on Wednesday May 26, 2010 @01:42AM
(#1379614)
What you want is __attribute__((unused)), assuming you're compiling with gcc.
Re:Android Project Changeset 4f8b683: libc/memset.c
by tedunangst on Tuesday May 25, 2010 @10:17PM
(#1379318)
Then you get a "statement with no effect" warning, which is usually more serious. I'll take a bogus warning in real code over a bogus warning in contrived code any day.
Re:Android Project Changeset 4f8b683: libc/memset.c
by cperciva on Tuesday May 25, 2010 @10:50PM
(#1379362)
I've never seen a compiler issue a warning about "(void)foo;". Even compilers which issue 'statement with no effect' warnings normally recognize deliberate casts to void as a way of saying "shut up, I know what I'm doing".