From owner-freebsd-current@FreeBSD.ORG Sat Jan 22 13:05:34 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 265D616A4D0 for ; Sat, 22 Jan 2005 13:05:34 +0000 (GMT) Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id 949F343D1F for ; Sat, 22 Jan 2005 13:05:33 +0000 (GMT) (envelope-from schweikh@schweikhardt.net) Received: by bremen.shuttle.de (Postfix, from userid 10) id 71FE73B8D3; Sat, 22 Jan 2005 14:05:32 +0100 (CET) Received: from hal9000.schweikhardt.net (localhost [127.0.0.1]) j0MD5DuM005888; Sat, 22 Jan 2005 14:05:13 +0100 (CET) (envelope-from schweikh@hal9000.schweikhardt.net) Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.13.1/8.13.1/Submit) id j0MD5DZg005887; Sat, 22 Jan 2005 14:05:13 +0100 (CET) (envelope-from schweikh) Date: Sat, 22 Jan 2005 14:05:13 +0100 From: Jens Schweikhardt To: Thomas Dickey Message-ID: <20050122130513.GB1951@schweikhardt.net> References: <20050116144113.GB66854@gothmog.gr> <41EAB5FE.30603@freebsd.org> <20050116193757.GA10974@saltmine.radix.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050116193757.GA10974@saltmine.radix.net> User-Agent: Mutt/1.5.6i cc: freebsd-current@freebsd.org Subject: Re: gratuitous gcc warnings: unused function arguments? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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: Sat, 22 Jan 2005 13:05:34 -0000 On Sun, Jan 16, 2005 at 02:37:57PM -0500, Thomas Dickey wrote: # On Sun, Jan 16, 2005 at 10:44:14AM -0800, Tim Kientzle wrote: # > Giorgos Keramidas suggested: # > > # > >% (void)argv; # > # > I first saw this idiom for marking unused # > arguments over 10 years ago and have used # > it extensively since then. Very portable; # > highly recommended. # # except of course for the compilers that warn about no effect... All compilers I have used (which includes embedded compilers) would warn about "no effect" only for argv; but shut up for (void)argv; The most portable solution involves some redundancy, e.g. simply using all args. May look ugly to some eyes and may be outright confusing for ten arg functions where you only "use" the last one. if (argc != 1 || argv[1] != 0) { ... } and variations thereof. Note that argc != 1 catches the "impossible" case of argc == 0. On a more philosophical note, it could be argued that a function using its second arg implicitly uses its first arg :-) Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped)