encyclopegia.org

void type

The void type, in several programming languages, more so curly bracket programming languages derived from C and ALGOL 68, is the return type of a function that returns normally, but provides no result value to its caller. Usually such functions are called for their side effects, such as performing some task or writing to their input parameters. The use of the void data type in such context is comparable to procedures in Pascal and syntactic constructs which define subroutines in Visual Basic. It is also similar to the unit type used in functional programming languages and type theory. See Unit type#In programming languages for a comparison. C and C++ also support the void pointer (or pointer to void type), denoted void* , but this is an unrelated notion. Variables of this type are pointers to data of an unspecified type, so in this context (but not the others) void* acts roughly like a universal or any type; it does not literally "point" to a void in memory. A program can convert a pointer to any type of data (except a function pointer) to a pointer to void and back to the original type without losing information, which makes these pointers useful for polymorphic functions. The C language standard does not guarantee that the different pointer types have the same size or alignment.

The void type, in several programming languages, more so curly bracket programming languages derived from C and ALGOL 68, is the return type of a function that returns normally, but provides no result value to its caller. Usually such functions are called for their side effects, such as performing some task or writing to their input parameters. The use of the void data type in such context is comparable to procedures in Pascal and syntactic constructs which define subroutines in Visual Basic. It is also similar to the unit type used in functional programming languages and type theory. See Unit type#In programming languages for a comparison. C and C++ also support the void pointer (or pointer to void type), denoted void* , but this is an unrelated notion. Variables of this type are pointers to data of an unspecified type, so in this context (but not the others) void* acts roughly like a universal or any type; it does not literally "point" to a void in memory. A program can convert a pointer to any type of data (except a function pointer) to a pointer to void and back to the original type without losing information, which makes these pointers useful for polymorphic functions. The C language standard does not guarantee that the different pointer types have the same size or alignment. ==In C and C++== A function with void result type ends either by reaching the end of the function or by executing a return statement with no returned value. The void type may also replace the argument list of a function prototype to indicate that the function takes no arguments. Note that in all of these situations, void is not a type qualifier on any value. Despite the name, this is semantically similar to an implicit unit type, not a zero or bottom type (which is sometimes confusingly called the "void type"). Unlike a real unit type which is a singleton, the void type lacks a way to represent its value and the language does not provide any way to declare an object or represent a value with type void . In other C-derived languages, such as Java and C#, void exists similarly with the same use. While Java does not have explicit pointers, C# has void* inside of unsafe blocks. In the earliest versions of C, functions with no specific result defaulted to a return type of int and functions with no arguments simply had empty argument lists. Pointers to untyped data were declared as integers or pointers to char . Some early C compilers had the feature, now seen as an annoyance, of generating a warning on any function call that did not use the function's returned value. Old code sometimes casts such function calls to void to suppress this warning. By the time Bjarne Stroustrup began his work on C++ in 1979–1980, void and void* were part of the C language dialect supported by AT&T-derived compilers. The explicit use of void vs. giving no arguments in a function prototype had different semantics in C and C++, as detailed in this table: The C syntax to declare a (non-variadic) function with an as-yet-unspecified number of parameters, e.g. void f() above, was deprecated in C99. In C23 (and C++), a function prototype with empty parentheses declares a function with zero parameters. In C and C++, one can write a "void cast" to explicitly indicate to discard a value. void f(maybe_unused int a, int b) { (void)a; return b; } ==In Haskell== In contrast to C++, in the functional programming language Haskell, the void type denotes the empty type, which has no inhabitants. A function into the void type does not return results, and a side-effectful program with type signature IO Void does not terminate, or crashes. In particular, there are no total functions into the void type. In functional programming, the unit type would replace the use of the void type in C. This type has a unique result which provides no new information. ==In Rust== In Rust's foreign function interface, there exists a std::ffi::c_void type equivalent to C/C++ void . There is no native void in Rust, as it uses the unit type () . ==See also== Null pointer ==References==

References

  1. The Development of the C Language · retrieved 2026-11-18 · rev 1332164462
    Cite this reference

    MLA "The Development of the C Language." Ritchie, Dennis M. 2026-11-18. https://en.wikipedia.org/wiki/Dennis_Ritchie. Accessed 24 November 2026.

    Chicago "The Development of the C Language." Ritchie, Dennis M. 2026-11-18. https://en.wikipedia.org/wiki/Dennis_Ritchie.

    APA Ritchie, Dennis M. (2026). The Development of the C Language. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Dennis_Ritchie

  2. Stroustrup, Bjarne (2009). Programming: Principles and Practice Using C++ . Boston: Addison-Wesley. p. 996. ISBN 978-0-321-54372-1 . Wikipedia revision 1332164462, retrieved 2026-11-19 · retrieved 2026-11-18 · rev 1332164462
    Cite this reference

    MLA "Stroustrup, Bjarne (2009). Programming: Principles and Practice Using C++ . Boston: Addison-Wesley. p. 996. ISBN 978-0-321-54372-1 . Wikipedia revision 1332164462, retrieved 2026-11-19." Stroustrup, Bjarne (2009). 2026-11-18. https://en.wikipedia.org/wiki/Bjarne_Stroustrup. Accessed 24 November 2026.

    Chicago "Stroustrup, Bjarne (2009). Programming: Principles and Practice Using C++ . Boston: Addison-Wesley. p. 996. ISBN 978-0-321-54372-1 . Wikipedia revision 1332164462, retrieved 2026-11-19." Stroustrup, Bjarne (2009). 2026-11-18. https://en.wikipedia.org/wiki/Bjarne_Stroustrup.

    APA Stroustrup, Bjarne (2009). (2026). Stroustrup, Bjarne (2009). Programming: Principles and Practice Using C++ . Boston: Addison-Wesley. p. 996. ISBN 978-0-321-54372-1 . Wikipedia revision 1332164462, retrieved 2026-11-19. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Bjarne_Stroustrup

  3. Bjarne Stroustrup, C and C++: Case Studies in Compatibility. Reconcilable differences? You decide , Dr. Dobb's , September 01, 2002; print version Wikipedia revision 1332164462, retrieved 2026-11-19 · retrieved 2026-11-18 · rev 1332164462
    Cite this reference

    MLA "Bjarne Stroustrup, C and C++: Case Studies in Compatibility. Reconcilable differences? You decide , Dr. Dobb's , September 01, 2002; print version Wikipedia revision 1332164462, retrieved 2026-11-19." Bjarne Stroustrup, C and C++: Case Studies in Compatibility. 2026-11-18. http://www.ddj.com/cpp/184401562. Accessed 24 November 2026.

    Chicago "Bjarne Stroustrup, C and C++: Case Studies in Compatibility. Reconcilable differences? You decide , Dr. Dobb's , September 01, 2002; print version Wikipedia revision 1332164462, retrieved 2026-11-19." Bjarne Stroustrup, C and C++: Case Studies in Compatibility. 2026-11-18. http://www.ddj.com/cpp/184401562.

    APA Bjarne Stroustrup, C and C++: Case Studies in Compatibility. (2026). Bjarne Stroustrup, C and C++: Case Studies in Compatibility. Reconcilable differences? You decide , Dr. Dobb's , September 01, 2002; print version Wikipedia revision 1332164462, retrieved 2026-11-19. Retrieved November 24, 2026, from http://www.ddj.com/cpp/184401562

  4. C and C++ Patterns - CS 61 · retrieved 2026-11-18 · rev 1332164462
    Cite this reference

    MLA "C and C++ Patterns - CS 61." 2026-11-18. https://cs61.seas.harvard.edu/site/2025/Patterns/#cast-to-void. Accessed 24 November 2026.

    Chicago "C and C++ Patterns - CS 61." 2026-11-18. https://cs61.seas.harvard.edu/site/2025/Patterns/#cast-to-void.

    APA encyclopegia.org. (2026). C and C++ Patterns - CS 61. Retrieved November 24, 2026, from https://cs61.seas.harvard.edu/site/2025/Patterns/#cast-to-void

  5. void · retrieved 2025-07-13 · rev 1332164462
    Cite this reference

    MLA "void." 2025-07-13. https://hackage.haskell.org/package/void. Accessed 24 November 2026.

    Chicago "void." 2025-07-13. https://hackage.haskell.org/package/void.

    APA encyclopegia.org. (2025). void. Retrieved November 24, 2026, from https://hackage.haskell.org/package/void

  6. WG14-N2432: Remove support for function definitions with identifier lists proposal · retrieved 2026-11-18 · rev 1332164462
    Cite this reference

    MLA "WG14-N2432: Remove support for function definitions with identifier lists proposal." "WG14-N2432: Remove support for function definitions with identifier lists proposal" (PDF). 2026-11-18. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf. Accessed 24 November 2026.

    Chicago "WG14-N2432: Remove support for function definitions with identifier lists proposal." "WG14-N2432: Remove support for function definitions with identifier lists proposal" (PDF). 2026-11-18. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf.

    APA "WG14-N2432: Remove support for function definitions with identifier lists proposal" (PDF). (2026). WG14-N2432: Remove support for function definitions with identifier lists proposal. Retrieved November 24, 2026, from https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf

  7. WG14-N2841: No function declarators without prototypes · retrieved 2026-11-18 · rev 1332164462
    Cite this reference

    MLA "WG14-N2841: No function declarators without prototypes." 2026-11-18. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm. Accessed 24 November 2026.

    Chicago "WG14-N2841: No function declarators without prototypes." 2026-11-18. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm.

    APA encyclopegia.org. (2026). WG14-N2841: No function declarators without prototypes. Retrieved November 24, 2026, from https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm

  8. void type · retrieved 2026-11-23 · rev 1332164462
    Cite this reference

    MLA "void type." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1332164462. Accessed 24 November 2026.

    Chicago "void type." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1332164462.

    APA encyclopegia.org. (2026). void type. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1332164462

Cite this article

MLA

"void type." encyclopegia.org, 2026, https://encyclopegia.org/wiki/void-type. Accessed 24 November 2026.

Chicago

"void type." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/void-type.

APA

encyclopegia.org. (2026). void type. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/void-type

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
year mentioned1979article body
year mentioned1980article body

Related articles

medical school

stub · references available

origin of language

stub · references available

To Build a Fire

stub · references available

anejaculation

stub · references available

Bridled nail-tail wallaby

stub · references available
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1332164462 · 0.55 · snapshot void-type-059047-cf810da9ac43b7a7 · QID Q513000

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.