From owner-freebsd-current@FreeBSD.ORG Fri Jul 27 12:31:36 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 7AE6B106566B for ; Fri, 27 Jul 2012 12:31:36 +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 3B5E58FC08 for ; Fri, 27 Jul 2012 12:31:36 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 914C27300A; Fri, 27 Jul 2012 14:51:34 +0200 (CEST) Date: Fri, 27 Jul 2012 14:51:34 +0200 From: Luigi Rizzo To: Poul-Henning Kamp Message-ID: <20120727125134.GA58187@onelab2.iet.unipi.it> References: <20120727093824.GB56662@onelab2.iet.unipi.it> <9654.1343388048@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9654.1343388048@critter.freebsd.dk> User-Agent: Mutt/1.4.2.3i Cc: current@freebsd.org Subject: Re: (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 12:31:36 -0000 On Fri, Jul 27, 2012 at 11:20:48AM +0000, Poul-Henning Kamp wrote: > In message <20120727093824.GB56662@onelab2.iet.unipi.it>, Luigi Rizzo writes: > > >The alternative way to avoid an 'unused' warning from the compiler > >is an empty statement > > > > (void)foo; > > The thing I don't like about this form, is that it doesn't communicate > your intention, only your action. > > Somewhere down my TODO list I have an item to propose instead: > > typedef void unused_t; > > int main(int argc, char **argv) > { > > (unused_t)argc; > (unused_t)argv; > return (0); > } i certainly like this better, my only concern is that some other platform might come with an incompatible usage of the name 'unused_t' same as it happened for __unused, and we are back with the problem. A comment might be used to explain the intention in even more detail: (void)foo; /* unused on XyBSD and Babbage-OS */ cheers luigi