[TUHS] Mac OS X is Unix

Lyndon Nerenberg lyndon at orthanc.ca
Wed Jan 4 07:39:40 AEST 2017


> #ifdef LINUX
> 	linux code
> #else
> 	default unix code
> #endif
> 
> instead of the much cleaner
> 
> 	if(LINUX)
> 		linux code
> 	else
> 		default unix code
> 
> In early days the latter would have cluttered precious memory
> with unfreachable code, but now we have optimizing compilers
> that will excise the useless branch just as effectively as cpp.

Plan 9 refreshingly evicted this nonsense from the native compilers (mostly) and the code base.[1]

I remember reading a Usenet post from the mid-late 80s that showed a roughly 40 line sequence of #foo hell from some bit of SVRx code.  There wasn't a single line of actual C there.  That it involved conditionalizing around the tty/termio drivers and some machine-specific ioctl goop ... well, let's not go *there*.

It might have been posted as an example for the Obfuscated C Contest.  It certainly could have won. (Assuming an entry without any actual C code was eligible.  Vague memories say anything that survived 'cc -o foo xxx.c [...]' was allowed.)

--lyndon

[1] Eliminating many binary APIs -- e.g. ioctl() -- in favour of textual ones, was a stroke of genius.  Not just with fileservers (/net et al), but also with things like dial().


More information about the TUHS mailing list