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