The 'void' Keyword in C Has Four Uses — More Than You Might Expect
The 'void' keyword in C has four distinct uses, which is one more than the often-cited three uses of 'static'. The keyword was not part of the original K&R dialect of C, where functions with no return value simply omitted the return type and were assumed to return int. Stephen Bourne, creator of the Bourne Shell, pushed for its addition after finding this ambiguity frustrating, and Dennis Ritchie agreed since explicitly returning nothing could save a machine instruction. Later, 'void' was reused to indicate that a function takes no parameters when C adopted function prototypes back-ported from C++, ensuring backward compatibility with older code. The keyword has since influenced several other programming languages, including Java, C#, D, and Swift.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in