|HP-UX Reference > U
unifdef(1)HP-UX 11i Version 3: February 2007
unifdef — remove preprocessor lines
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:
The unifdef command returns the following exit values:
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 100 CONTINUE #endif END
The command sequence:
unifdef -DANSI77 -UDEBUG -DTEST foo.f > /tmp/foo.f
produces the following result in file /tmp/foo.f:
PROGRAM TEST1 INTEGER I, J DO I=1,10 J=J+1 PRINT *,J ENDDO END
Any symbol name defined in the file must be specified in the unifdef command line; otherwise, unifdef will ignore the line.