1void(3type)                                                        void(3type)
2
3
4

NAME

6       void - abstract type
7

SYNOPSIS

9       void *
10

DESCRIPTION

12       A  pointer to any object type may be converted to a pointer to void and
13       back.  POSIX further requires that any pointer, including  pointers  to
14       functions, may be converted to a pointer to void and back.
15
16       Conversions from and to any other pointer type are done implicitly, not
17       requiring casts at all.  Note that this feature prevents  any  kind  of
18       type checking: the programmer should be careful not to convert a void *
19       value to a type incompatible to that of the  underlying  data,  because
20       that would result in undefined behavior.
21
22       This  type  is  useful in function parameters and return value to allow
23       passing values of any type.  The function will typically use some mech‐
24       anism  to  know the real type of the data being passed via a pointer to
25       void.
26
27       A value of this type can't be dereferenced, as it would give a value of
28       type  void, which is not possible.  Likewise, pointer arithmetic is not
29       possible with this type.  However, in GNU C, pointer arithmetic is  al‐
30       lowed  as  an  extension  to the standard; this is done by treating the
31       size of a void or of a function as 1.  A consequence of  this  is  that
32       sizeof is also allowed on void and on function types, and returns 1.
33
34   Use with printf(3) and scanf(3)
35       The  conversion specifier for void * for the printf(3) and the scanf(3)
36       families of functions is p.
37

VERSIONS

39       The POSIX requirement about compatibility between void *  and  function
40       pointers was added in POSIX.1-2008 Technical Corrigendum 1 (2013).
41

STANDARDS

43       C11, POSIX.1-2008.
44

HISTORY

46       C89, POSIX.1-2001.
47

SEE ALSO

49       malloc(3), memcmp(3), memcpy(3), memset(3), intptr_t(3type)
50
51
52
53Linux man-pages 6.04              2023-03-30                       void(3type)
Impressum