void casts; and C definition question

Dave Decot decot at cwruecmp.UUCP
Fri Oct 7 11:08:34 AEST 1983


The form

    (void) foo(x);

as a statement intended to "throw away" the value returned by foo(x) IS
correct, because it is a CAST operation on the expression

    foo(x);

which (apparently) has some non-void value.  The expression

    (void) foo(x);

still does have a "value" of sorts, but the "value" is of type void, whose
"conversion" rules are that any attempt to convert its values to any other
type (or to otherwise use void "values") is an error.  It is an therefore an
ERROR to ask for

    ((void) foo)(x);

because an expression of type void, i.e.

    ((void) foo)

cannot be where a function pointer (like foo) is required.

				Dave Decot
				..!decvax!cwruecmp!decot



More information about the Comp.lang.c mailing list