What is void in C?

What does void mean in C? I think it’s confusing to think of it having a singular meaning. It is part of a number of unrelated syntactic forms, and should be understood separately in each:

It is confusing to call void a “type”. There are positions where a normal type (int) can be used, but void cannot. For example, int foo; is a valid declaration, but void foo; is not. There are also positions where void can be used, but a normal type cannot. For example, char foo(int) { return 'c'; } is not a valid function definition.

The standard calls void an “incomplete type”, but I find this unenlightening in the case of char bar(void).


I wrote this because I felt like it. This post is my own, and not associated with my employer.

Jim. Public speaking. Friends. Vidrio.