More ANSI comment help wanted: #define void int vs. #define void char

Doug Gwyn gwyn at brl-smoke.ARPA
Mon Jun 6 10:21:15 AEST 1988


In article <8085 at elsie.UUCP> ado at elsie.UUCP (Arthur David Olson) writes:
>The response I received (was marked "Not an official X3J11 document"),
>said that while "#define void char" might be better when it comes to pointers,
>there were other cases where "#define void int" was better.  Can anyone give a
>concrete example?

There have been compilers that either did not know about "void" at all,
or that had various breakages involving e.g. pointers to functions
returning void (some of the Berkeley compilers had that problem).

Thus, when compiling code such as
	void func() { extern void exit(); /* ... */ }
it has often been useful to do the equivalent of "cc -Dvoid=int file.c".
Using char instead of int would not only gain nothing, but it would
introduce possible error (since in such an implementation, exit() would
probably be defaulted to return int).  Until recently, there has not been
code containing void *, but there has been lots of code like the above
example.



More information about the Comp.lang.c mailing list