Conversion to void*

C pointers are not necessarily the same size as type int. Pointer arguments given to functions should be explicitly cast to ensure that the correct type expected by the function is being passed. The generic object pointer in C is void*, but there is no generic function pointer.

Any pointer to an object, optionally type-qualified, can be converted to void*, keeping the same const or volatile qualifications.

C only

The allowable assignment conversions involving void* as the left operand are shown in the following table.

Table 17. Legal assignment conversions in C for void*
Left operand type Permitted right operand types
(void*)
  • The constant 0.
  • A pointer to an object. The object may be of incomplete type.
  • (void*)
End of C only
C++ only

Pointers to functions cannot be converted to the type void* with a standard conversion: this can be accomplished explicitly, provided that a void* has sufficient bits to hold it.

End of C++ only

Related information



[ Top of Page | Previous Page | Next Page | Contents | Index ]