Void type

Void type

The void type, in several programming languages derived from C and Algol68, is the type for the result of a function that produces no direct result. Usually such functions are called for their side effects, much like subroutines in Visual Basic and procedures in Pascal. 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. In C, the void type also appears in the argument lists of function prototypes to indicate that the function takes no arguments. Note that despite the name, in all of these situations, the void type serves as a unit type, not as a zero or bottom type. The language does not provide any way to declare an object or represent a value with type void.

C and C++ also support the type "pointer to void" (specified as void *), which has little to do with the other uses of void. Variables of this type are pointers to data of an unspecified type, so in this context (but not the others) void acts as a universal or top type. A program can convert a pointer to any type of data to a pointer to void and back to the original type without losing information, which makes these pointers useful for polymorphic functions.

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 pointers were part of the C language dialect supported by AT&T-derived compilers. [http://cm.bell-labs.com/cm/cs/who/dmr/chist.html, "Standardisation."]

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Void — may refer to:In fiction: * Void (comics), character from WildC.A.T.S. * Void ( Mortal Kombat ), a fictional location or realm in Mortal Kombat * Void , one of the minor villains in Sonic the Hedgehog * Void 1.1, a science fiction wargame created… …   Wikipedia

  • Void (album) — Infobox Album | Name = Void Type = studio Artist = Intronaut Released = August 23, 2006 Recorded = Early April, 2006 Shiva Industries in Santa Ana, California Genre = Post metal Progressive metal Length = 43:22 Label = Goodfellow Producer = John… …   Wikipedia

  • Void —  Pour la commune française, voir Void Vacon. En programmation, void est un mot clé que l on retrouve dans le langage C et plusieurs autres langages de programmation dont il est à l origine, comme le C++, le C# ou le Java. Ce mot clé void… …   Wikipédia en Français

  • Type unite — Type unité Un type unité est un type mathématique avec une seule valeur. L ensemble associé avec le type unité peut être n importe quel ensemble singleton. Il y a un isomorphisme entre deux tels ensembles, donc on parle souvent du type unité et… …   Wikipédia en Français

  • Type O Negative — Основная информация …   Википедия

  • void — У этого термина существуют и другие значения, см. Void (значения). void тип, спецификатор типа и ключевое слово в языках программирования Си, Си++, Java, C#,Objective C, D и ActionScript. Содержание 1 История 2 …   Википедия

  • void — Pour la commune française, voir Void Vacon. Pour le fromage, voir Void (fromage). En programmation, void est un mot clé que l on retrouve dans le langage C et plusieurs autres langages de programmation dont il est à l origine, comme le C++, le …   Wikipédia en Français

  • Type O Negative — This article is about the band. For the blood type, see blood type. Type O Negative Type O Negative performing at Columbiahalle in Berlin, Germany Background information Origin …   Wikipedia

  • Void-Vacon — 48° 41′ 19″ N 5° 37′ 08″ E / 48.6886111111, 5.61888888889 …   Wikipédia en Français

  • Type unité — Un type unité est un type mathématique avec une seule valeur. L ensemble associé avec le type unité peut être n importe quel ensemble singleton. Il y a un isomorphisme entre deux tels ensembles, donc on parle souvent du type unité et on ignore… …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”