warning: unfinished nonfunctional work in progress
unifdef utility is a partial C and C++ preprocessor.
It can expand just the macros you want expanded,
#if conditional directves,
#if controlling expressions.
It does not process
It preserves whitespace and comments.
It is useful for manipulating code that uses
#ifdef heavily for
portability: my original motivation for
unifdef was to understand
pty handling code.
It can be used as a lightweight preprocessor; for example the Linux
kernel uses an older version od
unifdef to strip
#ifdef __KERNEL__ sections from the headers it exports to
unifdef(1) man page describes:
the command-line usage
details of how
unifdef preprocesses your code
notes on standards conformance
This is version 3 of
unifdef. There is a summary of
differences between unifdef3 and unifdef2.
Browse the source repository at: https://dotat.at/cgi/git/unifdef3.git
Clone the development repository with:
git clone https://dotat.at/git/unifdef3.git
Release tar and zip files contain the complete source in
which is mostly standard C, except that it uses
<unistd.h>. There is no build-time configuration, so you can usually
compile it by just running:
To run the tests you will need
awk. We use perl's
If you are building from the git repository you need a few external
dependencies. You can build and install them in an
This will download, verify checksums, and buid:
The regex-based lexical analyser in the source
is compiled to a big DFA in
A small unit test framework.
unifdef(1) man page into nice HTML.
Other documentation is formatted with markdown.
I assume your OS has
markdown and the build tooling in
scripts subdirectory, as well as the tests.
Please send bug reports, suggestions, and patches by email to me,
Tony Finch <firstname.lastname@example.org>. Any contribution that you want
unifdef must be licensed under the CC0 1.0 Public
Domain Dedication, and must include a
to certify that you wrote it or otherwise have the right to pass
it on as a open-source patch, according to the Developer's
Certificate of Origin 1.1.
unifdefis written by Tony Finch <email@example.com>
You may do anything with this. It has no warranty.
The test code in the
unifdef distribution (but not the git
entapment which were
written by Scott Vokes <firstname.lastname@example.org> and distributed under
the ISC license.