void(3type)
π void(3type) β the abstract type that ate π
okay bestie, welcome to the void(3type) page β that's section 3type, the little corner of the manual for type pages, not functions. and listen, this one is short but it is iconic, because void is the type that literally means "idk what this is and that's the point." β¨
πΈ NAME πΈ
void β abstract type. that's it. that's the whole name. no notes. π
π¦ SYNOPSIS π¦
void *
yeah. that's the star of the show. the pointer, not the type itself. because a plain void value? can't even exist, bestie. we'll get there. π
β¨ DESCRIPTION β¨
so here's the tea: a pointer to any object type can be converted to a pointer to void, and back again</p>. no drama, no fuss.
and POSIX goes even harder β it further requires that any pointer, including pointers to functions, may be converted to a pointer to void and back. yes, function pointers too. slay. π
okay so the conversions from and to any other pointer type just... happen. implicitly. you don't need casts at all. it's giving effortless. π§
but β and this is the important part, so pay attention β that feature means there is NO type checking whatsoever. none. the compiler is not your mom here.
β οΈ bestie. be careful. if you convert a void * value to a type that's incompatible with the type of the underlying data, that is undefined behavior. like, the bad kind. the "your program is now haunted" kind. π
why is this type even useful though? because in function parameters and return values, it lets you pass values of any type. π
a function taking a void * can accept whatever you throw at it.
the catch: the function will typically need some mechanism to know the real type of the data being passed via that pointer to void. it doesn't magically know. somebody's gotta tell it. iykyk. π
two things you cannot do with a value of this type:
- you can't dereference it β that would give you a value of type
void, which is not possible. literally not a thing that can exist. - you can't do pointer arithmetic with it β nope, not allowed.
however (and this is such a GNU C moment π«Ά) β in GNU C, pointer arithmetic is allowed as an extension to the standard. how? by treating the size of a void or of a function as 1.
and the consequence of that is: sizeof is also allowed on void and on function types, and returns 1. wild. iconic. definitely not portable, but go off GNU. π
π Use with printf(3) and scanf(3) π
okay so when you're using the printf(3) family or the scanf(3) family and you've got a void *, the conversion specifier you want is:
p
that's it. one letter. p. periodt. β
π VERSIONS π
the whole POSIX requirement about compatibility between void * and function pointers? that got added in POSIX.1-2008 Technical Corrigendum 1 (2013). so if you're on something older, don't come for POSIX, it wasn't there yet. π
π STANDARDS π
C11, POSIX.1-2024. certified. official. the vibes are standardized. β¨
π HISTORY π
C89, POSIX.1-1990. this type has been around for ages, bestie. vintage. but like, in a good way. πΈ
π SEE ALSO π
π and that's the whole page!! no cap. this was brought to you by Linux man-pages 6.20, dated 2026-02-08, from the void(3type) page. go convert some pointers, bestie, just don't cast them to the wrong type or it's undefined behavior o'clock ππ«Άβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2020, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms