void casts; and C definition question

Tim Maroney tim at unc.UUCP
Wed Oct 5 07:55:14 AEST 1983


The cited use of the (void) type cast is indeed incorrect if the operator
precedence rules of Kernighan and Ritchie are correct.  The example given
went like:

(void) foo(x);

to show that nothing important is returned from foo.  In fact, the
parentheses of the function call argument list group first, meaning that the
value returned by foo is a function of type void.  To do it right, you would
have to say:

((void) foo)(x);

I suppose that the rather sloppy definition of void in the public
documentation would allow you to make a weak case for the former being
correct, though.  Still, special properties of void notwithstanding, only
the latter form is correct.

Isn't C wonderful?  Wait, let me leave the room before you answer...

_________________________
Tim Maroney, duke!unc!tim



More information about the Comp.lang.c mailing list