From owner-freebsd-current@FreeBSD.ORG Mon Jan 17 00:42:11 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 63E8F16A4CE; Mon, 17 Jan 2005 00:42:11 +0000 (GMT) Received: from dragon.nuxi.com (trang.nuxi.com [66.93.134.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 290B343D5E; Mon, 17 Jan 2005 00:42:11 +0000 (GMT) (envelope-from obrien@NUXI.com) Received: from dragon.nuxi.com (obrien@localhost [127.0.0.1]) by dragon.nuxi.com (8.13.1/8.13.1) with ESMTP id j0H0gA68062445; Sun, 16 Jan 2005 16:42:10 -0800 (PST) (envelope-from obrien@dragon.nuxi.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.13.1/8.13.1/Submit) id j0H0g91h062444; Sun, 16 Jan 2005 16:42:09 -0800 (PST) (envelope-from obrien) Date: Sun, 16 Jan 2005 16:42:09 -0800 From: "David O'Brien" To: Garance A Drosihn Message-ID: <20050117004209.GA62371@dragon.nuxi.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 6.0-CURRENT Organization: The NUXI BSD Group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 cc: freebsd-current@freebsd.org cc: Robert Watson Subject: Re: gratuitous gcc warnings: unused function arguments? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: freebsd-current@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2005 00:42:11 -0000 On Sun, Jan 16, 2005 at 06:16:49PM -0500, Garance A Drosihn wrote: > In this specific case, would it make sense to change the code to be: > int > dummyfunction(int arg1, int arg2, char *argv) > { > > if (DUMMY_USES_ARGV && (argv != NULL)) > printf("dummyfunction: %s\n", argv); > return (arg1 + arg2); > } > > ? > > This does mean you must always define DUMMY_USES_ARGV to be 0 or 1 > (which is easy enough to do by using an #ifndef check up at the start > of the file). But it does remove the warning message (at least in gcc), > and in my testing it also seems to produce the same-size object-code > as the #ifdef version. I like this version much better. Requiring a #define symbol to be a set value isn't so bad. In fact it is a requirement in GCC'ville -- along with not using #ifdef, but rather "if(SYMBOL && )" so that all(most) code will be syntax checked an a build on arch system has less chance of breaking the build for another arch. -- -- David (obrien@FreeBSD.org)