Re: (void)foo or __unused foo ?

看板FB_current作者時間13年前 (2012/07/28 15:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串8/8 (看更多)
On Jul 27, 2012, at 2:38 AM, Luigi Rizzo wrote: >=20 > The alternative way to avoid an 'unused' warning from the compiler > is an empty statement >=20 > (void)foo; >=20 > that the compiler hopefully optimizes away. I learned the void-cast convention many years ago. I used it throughout the libarchive code and have yet to run into any problems. I always use it in exactly this form (with the exact comment here) so that I can easily search on it: int foo(int a) { (void) a; /* UNUSED */ =85 } I agree with PHK that it would be nice to express this intent in a way that static checkers could verify. I also agree that having static checkers interpret comments is Evil. But I have yet to see any alternative that was as straightforward and widely-supported as this one. Every other viable alternative seems to require tangled clumps of macros. Tim _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1G4uulrK (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1G4uulrK (FB_current)