(void)foo or __unused foo ?

看板FB_current作者時間13年前 (2012/07/27 17:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/8 (看更多)
In writing cross platform code I often have to deal with function arguments or variables that are not used on certain platforms. In FreeBSD:sys/cdefs.h we have #define __unused __attribute__((__unused__)) and in the kernel we tend to annotate with "__unused" such arguments int f(type foo __unused) However on linux __unused is not a standard macro, and is often used as a variable or field name in standard headers, so introducing our __unused macro breaks compilation there. The alternative way to avoid an 'unused' warning from the compiler is an empty statement (void)foo; that the compiler hopefully optimizes away. Any disadvantage or objection to selectively use this form in our kernel code for parts that need to work on multiple platforms ? cheers luigi _______________________________________________ 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): #1G4c0J2E (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1G4c0J2E (FB_current)