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-unsubscr...@freebsd.org"

Reply via email to