unifdef.1 (2010 09)
u
unifdef(1) unifdef(1)
NAME
unifdef - remove preprocessor lines
SYNOPSIS
unifdef [-clt][[-D sym ][
-U sym ][-iD sym ][-iU sym ] ] ... [ file ]
DESCRIPTION
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,orendif. The # character and its associ-
ated 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.
Options
unifdef recognizes the following command-line options:
-c Complement the normal behavior by printing only the rejected lines.
-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.
RETURN VALUE
The
unifdef command returns the following exit values:
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,orendif.
EXAMPLES
Assume file
foo.f contains the following:
PROGRAM TEST1
INTEGER I, J
#ifdef ANSI77
DO I=1,10
#else
DO 100 I=1,10
#endif
J=J+1
#if defined (DEBUG) || defined (TEST)
PRINT *,J
#endif
#ifdef ANSI77
ENDDO
#else
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1