C: A reference Manual, Fifth Edition
Page 87,
4.4.1 Default Type Specifiers
Originally, C allowed the type specifier in a variable declaration or function to
be omitted, in which chase it defaulted to
int. This is considered bad programming style in
modern C, and in fact C99 treats it as an error.
Older compilers did not implement the
void type, so rationale behind omitting the type specifier on function definitions was to
indicate to human readers that the default function did not really return a value (although the com-
piler had to assume that it did).
Example
Code:
In pre-Standard C, it was common to see function definitions like this:
/* Sort v[0] ... vpn-1] into increasing order. */
sort(v, n)
int v[], n;
{
...
}
The modern, Standard C style is to declare those functions with the
void type:
Code:
/* Sort v[0] ... v[n-1] into increasing order. */
void sort(int v[], int n)
{
...
}
Example
When using a compiler that does not implement
void, it is much nicer to define
void your-
self and then use it explicitly than to omit the type specifier entirely:
Code:
/* Make "void" be a synonym for "int". */
typedef int void;
At least one compiler we know of actually reserves the identifier void, but does not imple-
ment it. For that compiler, the preprocessor definition
is one of the few cases in which using a reserved word as a macro name is justified.