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.

Similar posts

More by Jim

Want to build a fantastic product using LLMs? I work at Granola where we're building the future IDE for knowledge work. Come and work with us! Read more or get in touch!

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