From owner-freebsd-current@FreeBSD.ORG Fri Jul 27 09:18:26 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 026D11065670 for ; Fri, 27 Jul 2012 09:18:26 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id BAE138FC19 for ; Fri, 27 Jul 2012 09:18:25 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id E64217300B; Fri, 27 Jul 2012 11:38:24 +0200 (CEST) Date: Fri, 27 Jul 2012 11:38:24 +0200 From: Luigi Rizzo To: current@freebsd.org Message-ID: <20120727093824.GB56662@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: (void)foo or __unused foo ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2012 09:18:26 -0000 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