CKTIS / C
The void type
void represents the absence of a value. It appears as a function return type, a marker for no parameters, and part of the pointer type void *.
Version: C23; repository compiler flag, production runtime not attested
Syntax
void f(void);
void *p;
(void)expression;void is an incomplete type that cannot be completed; it has no values. You cannot define a void object or use sizeof(void) in standard C.
In void f(void), the first void means no returned value, and the second means no parameters. The function can exit using return;. In C23, void f() also means no parameters; in earlier versions, that declaration did not specify their number or types.
void * is a pointer, not an absence of a value. Converting an object pointer to void * and back preserves equality with the original pointer. Use the appropriate pointer type before accessing the object. Standard C does not allow arithmetic on void *; the conversion guarantee does not cover function pointers.
(void)expression discards the result while preserving evaluation's side effects. It does not check whether an operation succeeded.
Examples
#include <stdio.h>
static void show(void)
{
int value = 42;
void *p = &value;
int *q = p;
(void)printf("%d\n", *q);
}
int main(void)
{
show();
return 0;
}
Result
42
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.