Date: Sun, 16 Jan 2005 18:16:49 -0500 From: Garance A Drosihn <drosih@rpi.edu> To: Robert Watson <rwatson@freebsd.org>, current@freebsd.org Subject: Re: gratuitous gcc warnings: unused function arguments? Message-ID: <p06200722be10a1a3bf88@[128.113.24.47]> In-Reply-To: <Pine.NEB.3.96L.1050116120744.50371A-100000@fledge.watson.org> References: <Pine.NEB.3.96L.1050116120744.50371A-100000@fledge.watson.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p06200722be10a1a3bf88>