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).

Tagged #c, #programming, #void, #semantics.
👋 I'm Jim, a full-stack product engineer. Want to build an amazing product and a profitable business? Read more about me or Get in touch!

More by Jim

This page copyright James Fisher 2016. Content is not associated with my employer. Found an error? Edit this page.