gratuitous gcc warnings: unused function arguments?

David O'Brien obrien at freebsd.org
Sun Jan 16 16:42:11 PST 2005


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 at FreeBSD.org)


More information about the freebsd-current mailing list