8 comments

[ 4.4 ms ] story [ 30.5 ms ] thread
This is an old Unix utility, OpenBSD versions <=5.5 shipped with a much older version from CSRG times. It was recently updated to the rewrite done by Tony Finch.

http://dotat.at/prog/unifdef/

A refactoring tool from the days where "refactoring" didn't exist
Refactoring always existed. We just didn't have a name for it and it was done by us meat popsicles.
The first known use of the term "refactoring" in the published literature was in a September, 1990 article by William Opdyke and Ralph Johnson - "Refactoring: An Aid in Designing Application Frameworks and Evolving Object-Oriented Systems". Proceedings of the Symposium on Object Oriented Programming Emphasizing Practical Applications (SOOPPA). ACM.
Super useful tool once you realize that you need it. I used it extensively with the QEMU sources where all the supported architectures are essentially just ifdefs in the code. There is also an improved `sunifdef` flying around in the interwebs.
Yup, I've also used it (the old version, I guess) to great effect to clean up a legacy code base which had defines for things like Amiga and VMS...
I wish more manpages would include a brief explanation of why you might want to use the tool. For someone stumbling across this utility, the documentation is baffling.
Trim unused code paths from ancient C code, usually work-arounds and legacy platform support. Or trim large accumulations of #if 0 that similarly build up in old C code bases.