why is free() a void?

Doug Gwyn gwyn at smoke.brl.mil
Wed Nov 7 20:04:05 AEST 1990


In article <2604 at cirrusl.UUCP> dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
>Both free() and (*handler)() used to return int at one time.

They certainly did not.

Before the "void" type was added to the C language, the only way to declare
or define a function that didn't return a value was to just omit its return
type.  Unfortunately, as a programmer convenience the common type "int" was
also permitted to be elided in many declarations, including as the return
type for a function declaration/definition.  Thus, an actually-void function
had type indistinguishable from function-returning-int.  After "void" was
added, we cleaned up this overloading.  Old-style actually-void function
code for the most part will continue to work, signal handlers being the
notable exception.  (And even they generally continue to work in nearly all
implementations.)



More information about the Comp.lang.c mailing list