unifdef - remove preprocessor lines
unifdef [-clt] [[-D sym] [-U sym] [-iD sym] [-iU sym]] ... [file]
unifdef simulates some of the actions of cpp in interpreting C
language preprocessor command lines (see cpp(1)). For unifdef, a
valid preprocessor command line contains as its first character a #
and one of the following keywords: ifdef, ifndef, if, else, or endif.
The # character and its associated keyword must appear on the same
line, but they can be separated by spaces, tabs, and commented text.
When appropriate, the portions of code surrounded by and including the
targeted preprocessor directives are removed, and the resultant text
is written to the standard output.
Unlike cpp, unifdef does not insert included files, interpret macros,
or strip comment lines. This means, among other things, that #define
and #undef macros occurring within the input text are not interpreted.
Since unifdef is language-independent, it can be used for processing
source files for languages other than the C language. For example,
unifdef can be used on FORTRAN language source files, provided the C
language preprocessor commands are used.
unifdef recognizes the following command-line options:
-c Complement the normal behavior by printing only the
-iDsym Ignore text delimited by #ifdef sym. In other words,
text that would otherwise be affected by some action
is not touched when found within the context of a
preprocessor command using sym.
-iUsym Ignore text delimited by #ifndef sym.
-l Replace rejected lines with blank lines in the text
written to the standard output.
-t Treat the input source as plain text. C-language
comment and quoting constructs are not recognized.
-Dsym Define symbol sym.
-Usym Cause symbol sym to be undefined.
The unifdef command returns the following exit values:
Hewlett-Packard Company - 1 - HP-UX Release 11i: November 2000
0 Output is an exact copy of the input.
1 Output is not an exact copy of the input.
2 The unifdef command fails. The failure might be due
to a premature EOF or to an inappropriate else, elif,
Assume file foo.f contains the following:
INTEGER I, J
DO 100 I=1,10
#if defined (DEBUG) || defined (TEST)
The command sequence:
unifdef -DANSI77 -UDEBUG -DTEST foo.f >>>> /tmp/foo.f
produces the following result in file /tmp/foo.f:
INTEGER I, J
Any symbol name defined in the file must be specified in the unifdef
command line; otherwise, unifdef will ignore the line.
unifdef was developed in the public domain.
Hewlett-Packard Company - 2 - HP-UX Release 11i: November 2000
Hewlett-Packard Company - 3 - HP-UX Release 11i: November 2000