On Sun, May 20, 2007 at 04:01:27PM +0200, Giel van Schijndel wrote:
> Stefan Huehner schreef:
> > Author: shuehner
> > Date: Sun May 20 15:51:53 2007
> > New Revision: 1305
> >
> > URL: http://svn.gna.org/viewcvs/warzone?rev=1305&view=rev
> > Log:
> > 2 small fixes in function declarations : () -> (void)
> >
> > Modified:
> >     trunk/lib/netplay/netplay.c
> >     trunk/lib/sound/cdaudio.c
> >   
> According to the ISO C standard (both C89 and C99) this is _not_
> necessary. The only place where you need to use a function signature of
> `(void)`, to indicate a function taking no arguments, is in forward
> declarations, not in function definitions.

Hmm i haven't got the text here to look it up myself. But chaning i.e.
the static function declaration in cdaudio.c:58 to (void) removes the
following to warning from my gcc warning output:

-cdaudio.c:58: warning: function declaration isn't prototype
-cdaudio.c: In function: 'ProcessedBuffers':
-cdaudio.c:58: warning: old-style function definition

I'am compiling with additional -Wstrict-prototypes abd
-Wold-style-definition to catch these.

And for a direct improvement which comes in changing these i attach the
following 2 test-cases.

test1.c has the following 'static void test1()' and if you compile this
you'll notive that the compiler doesn't catch the function call in main
with an argument. I assume that i wanted to have the test1 function
without arguments.

test2.c is the same programs but with 'static void test1(void)'. Now the
compiler correctly catches the wrong function call.

Regards,
Stefan




static void test1() {
}

int main(int argc, char *argv[]) {
	test1(5);
	return 0;
}


static void test1(void) {
}

int main(int argc, char *argv[]) {
	test1(5);
	return 0;
}
_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to