70
The void cast is not necessary in the above example, but many programmers
use the cast to indicate that the return value is being intentionally ignored.
2.9.12.
Void Pointer (void *)
A pointer to void (i.e., void *), referred to as a generic pointer, has special
meaning to the compiler. A pointer to any type of object can be converted to a
void pointer and back again with the resultant and original pointers guaranteed
to compare equal. Additionally, void pointers and non-void pointers may appear
together in assignment and comparison expressions with no explicit type
conversion. The following examples demonstrate legal and illegal pointer
expressions:
2.10.
Conversions
The compiler provides for both the implicit and explicit conversion of values from
one type to another.
A value may be explicitly converted to another type with a cast operator.
•
An operand may be implicitly converted to another type so that a specific
•
arithmetic or logical operation can be performed.
An implicit conversion may result from the assignment of an object of one
•
type to an object of another type.
•
An argument to a function may be implicitly converted to another type in
preparation for the function call.
•
The value returned by a function may be implicitly converted to the function
return type before the function return.
2.10.1.
General Considerations
When a value of one type is converted to a value of another type, the internal
representation (i.e., bit pattern) may change. Conversions between floating-point
types and integer types always involve a change in representation. When
TI-89 / TI-92 Plus Sierra C Assembler Reference Manual
int * pi;
char * pc;
void * pv;
pv = pc;
/ * legal
pc = pi;
/ * illegal, cast required
pi ++ ;
/ * legal
pv + = 2;
/ * illegal, size of void pointer unknown
f( * pv )
/ * illegal to dereference a void pointer
Not for Distribution
Section 2: Compiler
* /
* /
* /
* /
* /
Beta Version February 2, 2001