void(3type) — Linux manual page

NAME | SYNOPSIS | DESCRIPTION | VERSIONS | STANDARDS | HISTORY | SEE ALSO | COLOPHON

void(3type)                                                  void(3type)

NAME         top

       void - abstract type

SYNOPSIS         top

       void *

DESCRIPTION         top

       A pointer to any object type may be converted to a pointer to
       void and back.  POSIX further requires that any pointer,
       including pointers to functions, may be converted to a pointer to
       void and back.

       Conversions from and to any other pointer type are done
       implicitly, not requiring casts at all.  Note that this feature
       prevents any kind of type checking: the programmer should be
       careful not to convert a void * value to a type incompatible to
       that of the underlying data, because that would result in
       undefined behavior.

       This type is useful in function parameters and return value to
       allow passing values of any type.  The function will typically
       use some mechanism to know the real type of the data being passed
       via a pointer to void.

       A value of this type can't be dereferenced, as it would give a
       value of type void, which is not possible.  Likewise, pointer
       arithmetic is not possible with this type.  However, in GNU C,
       pointer arithmetic is allowed as an extension to the standard;
       this is done by treating the size of a void or of a function as
       1.  A consequence of this is that sizeof is also allowed on void
       and on function types, and returns 1.

   Use with printf(3) and scanf(3)
       The conversion specifier for void * for the printf(3) and the
       scanf(3) families of functions is p.

VERSIONS         top

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

STANDARDS         top

       C11, POSIX.1-2008.

HISTORY         top

       C89, POSIX.1-2001.

SEE ALSO         top

       malloc(3), memcmp(3), memcpy(3), memset(3), intptr_t(3type)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.9.1.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2024-06-26.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       man-pages@man7.org

Linux man-pages 6.9.1          2024-05-02                    void(3type)

Pages that refer to this page: NULL(3const)