uses of void
- as the (non-) return value of a function that doesn't return anything
-
so it is a syntax error to have
return myval;
one must have onlyreturn;
- as (non-) type of pointer to raw memory,
- as is returned from
malloc()
. It is common to cast the pointer to a meaningful type:int *myIntArray = (int *)malloc( NUM_INTS * sizeof( int ) );
- the conversion to
(void *)
from a non-void *
does appear sometimes. -
This makes sense if the pointer is thereafter to be regarded as a pointer
to raw memory (as in
free()
ormemcpy()
). Otherwise, avoid it.