]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3type/void.3type
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3type / void.3type
1 .\" Copyright (c) 2020-2022 by Alejandro Colomar <colomar.6.4.3@gmail.com>
2 .\" and Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\"
7 .TH VOID 3type 2022-07-20 "Linux man-pages (unreleased)"
8 .SH NAME
9 void \- abstract type
10 .SH SYNOPSIS
11 .nf
12 .B void *
13 .fi
14 .SH DESCRIPTION
15 A pointer to any object type may be converted to a pointer to
16 .I void
17 and back.
18 POSIX further requires that any pointer,
19 including pointers to functions,
20 may be converted to a pointer to
21 .I void
22 and back.
23 .PP
24 Conversions from and to any other pointer type are done implicitly,
25 not requiring casts at all.
26 Note that this feature prevents any kind of type checking:
27 the programmer should be careful not to convert a
28 .I void *
29 value to a type incompatible to that of the underlying data,
30 because that would result in undefined behavior.
31 .PP
32 This type is useful in function parameters and return value
33 to allow passing values of any type.
34 The function will typically use some mechanism to know
35 the real type of the data being passed via a pointer to
36 .IR void .
37 .PP
38 A value of this type can't be dereferenced,
39 as it would give a value of type
40 .IR void ,
41 which is not possible.
42 Likewise, pointer arithmetic is not possible with this type.
43 However, in GNU C, pointer arithmetic is allowed
44 as an extension to the standard;
45 this is done by treating the size of a
46 .I void
47 or of a function as 1.
48 A consequence of this is that
49 .I sizeof
50 is also allowed on
51 .I void
52 and on function types, and returns 1.
53 .SS Use with printf(3) and scanf(3)
54 The conversion specifier for
55 .I void *
56 for the
57 .BR printf (3)
58 and the
59 .BR scanf (3)
60 families of functions is
61 .BR p .
62 .SH VERSIONS
63 The POSIX requirement about compatibility between
64 .I void *
65 and function pointers was added in
66 POSIX.1-2008 Technical Corrigendum 1 (2013).
67 .SH STANDARDS
68 C99 and later;
69 POSIX.1-2001 and later.
70 .SH SEE ALSO
71 .BR malloc (3),
72 .BR memcmp (3),
73 .BR memcpy (3),
74 .BR memset (3),
75 .BR intptr_t (3type)