From owner-freebsd-current@FreeBSD.ORG Sun Jan 16 23:16:51 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 DED2616A4CE; Sun, 16 Jan 2005 23:16:51 +0000 (GMT) Received: from smtp2.server.rpi.edu (smtp2.server.rpi.edu [128.113.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 636BE43D2F; Sun, 16 Jan 2005 23:16:51 +0000 (GMT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp2.server.rpi.edu (8.13.0/8.13.0) with ESMTP id j0GNGoDF005411; Sun, 16 Jan 2005 18:16:50 -0500 Mime-Version: 1.0 Message-Id: In-Reply-To: References: Date: Sun, 16 Jan 2005 18:16:49 -0500 To: Robert Watson , current@freebsd.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: default X-RPI-SA-Score: undef - spam-scanning disabled X-Scanned-By: CanIt (www . canit . ca) 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: Sun, 16 Jan 2005 23:16:52 -0000 At 12:18 PM +0000 1/16/05, Robert Watson wrote: >One of the reasons why I find __unused irritating is the >following sort of situation: > >int >dummyfunction(int arg1, int arg2, char *argv) >{ > >#ifdef DUMMY_USES_ARGV > if (argv != NULL) > printf("dummyfunction: %s\n", argv); >#endif > return (arg1 + arg2); >} > >With the new world order, we would have to ifdef the function >definition to conditionally use __unused in order to allow the >function to compile with or without the #ifdef. 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. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu