selectively remove C preprocessor conditionals (original) (raw)
The unifdef utility selectively processes conditional C preprocessor #if and #ifdef directives. It removes from a file both the directives and the additional text that they delimit, while otherwise leaving the file alone.
It is useful for avoiding distractions when studying code that uses#ifdef heavily for portability: my original motivation was to understand xterm's pty handling code. It can be used as a lightweight preprocessor; for examplethe Linux kernel uses unifdef to strip out#ifdef __KERNEL__ sections from the headers it exports to userland. You can use unifdef with languages other than C; for example UIT, a publisher in Cambridge where I live, usesunifdef with LaTeX.
- Download:
unifdef-2.12.tar.xz
unifdef-2.12.tar.gz
unifdef-2.12.zip - Read the manual
- Browse the source
- Clone my repository using
git clone git://dotat.at/unifdef.git - Collaborate usinggithub
- Copyright licence: BSD
- Build instructions for Unix and Windows
Please send bug reports and patches to me. Unless you state otherwise, I will assume that any contributions are under the two-clause BSD licence.
unifdef was written by Tony Finch <dot@dotat.at>