selectively remove C preprocessor conditionals
C Groff Shell HTML Makefile ApacheConf Other
Latest commit 87dfd91 Feb 26, 2016 @fanf2 portability: fix problems compiling with C++ compiler
Michael McConville suggested removing a "redundant" cast of
the return value from malloc(), based on a change in the
OpenBSD version of unifdef. This is a good suggestion for
a purely C program, but the cast is required in C++.

Carsten Hey contributed some portability improvements in
2012 which included this cast, so that unifdef can be
compiled with a C++ compiler. Unfortunately since then
there have been several regressions in C++ support.

This commit fixes those regressions.


unifdef - selectively remove C preprocessor conditionals

Written by Tony Finch <> -

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.

Please see the INSTALL file for installation instructions.

Pre-formatted documentation can be found in unifdef.txt

You can download the latest release tar and zip files from:

You can clone the development repository using:
	git clone

I also maintain a copy at
(Warning: GitHub's zip download is incomplete and unusable.)

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. See the COPYING file for details.

Thanks to the following people for their contributions:

Bob Proulx <>
 - test suite

Jonathan Nieder <>
 - bug fixes, improved unifdefall

Anders H Kaseorg <>
 - bug fixes and other improvements

Ruediger Meier <>
 - build and portability cleanups

Ben Hutchings at Solarflare Communications
 - lenient evaluation of && and ||

Steve Underwood <>
 - read #define and #undef directives from a file

Brian Ginsbach <>
 - improved expression evaluator

Other contributions are listed in the Changelog.

- end -