Main index | Section 1 | 日本語 | Options |
The
unifdef
utility acts on
#if, #ifdef, #ifndef,
#elif, #else,
and
#endif
lines,
using macros specified in
It understands a commonly-used subset of the expression syntax for #if and #elif lines: integer constants, integer values of macros defined on the command line, the defined() operator, the operators amp;!, ~, - (unary), *, /, %, +, -, <, <=, >, >=, ==, !=, &, ^, amp;|, &&, ||, and parenthesized expressions. Division by zero is treated as an unknown value. A kind of "short circuit" evaluation is used for the && operator: if either operand is definitely false then the result is false, even if the value of the other operand is unknown. Similarly, if either operand of || is definitely true then the result is true.
When evaluating an expression, unifdef does not expand macros first. The value of a macro must be a simple number, not an expression. A limited form of indirection is allowed, where one macro's value is the name of another.
In most cases,
unifdef
does not distinguish between object-like macros
(without arguments) and function-like macros (with arguments).
A function-like macro invocation can appear in
#if
and
#elif
control expressions.
If the macro is not explicitly defined,
or is defined with the
The unifdef utility understands just enough about C to know when one of the directives is inactive because it is inside a comment, or affected by a backslash-continued line. It spots unusually-formatted preprocessor directives and knows when the layout is too odd for it to handle.
A script called unifdefall can be used to remove all conditional cpp(1) directives from a file. It uses Fl and cpp to get lists of all the controlling macros and their definitions (or lack thereof), then invokes unifdef with appropriate arguments to process the file.
| |
Specify that a macro is defined to a given value.
| |
| |
Specify that a macro is defined to the value 1.
| |
| |
Specify that a macro is undefined.
If the same macro appears in more than one argument, the last occurrence dominates.
| |
| |
C strings, comments,
and line continuations
are ignored within
#ifdef
and
#ifndef
blocks
controlled by macros
specified with these options.
| |
| |
The file
defile
contains
#define
and
#undef
preprocessor directives,
which have the same effect as the corresponding
Each directive must be on a single line. Object-like macro definitions (without arguments) are set to the given value. Function-like macro definitions (with arguments) are treated as if they are set to 1.
Warning:
string literals and character constants are not parsed correctly in
| |
| |
Replace removed lines with blank lines
instead of deleting them.
Mutually exclusive with the
| |
| |
Compress blank lines around a deleted section.
Mutually exclusive with the
| |
| |
Complement,
i.e., lines that would have been removed or blanked
are retained and vice versa.
| |
| |
Turn on printing of debugging messages.
| |
| |
By default,
unifdef
will report an error if it needs to remove
a preprocessor directive that spans more than one line,
for example, if it has a multi-line
comment hanging off its right hand end.
The
| |
| |
Print help.
| |
| |
Specifies to
unifdefall
an additional place to look for
#include
files.
This option is ignored by
unifdef
for compatibility with
cpp(1)
and to simplify the implementation of
unifdefall.
| |
| |
Always treat the result of
&&
and
||
operators as unknown if either operand is unknown,
instead of short-circuiting when unknown operands can't affect the result.
This option is for compatibility with older versions of
unifdef.
| |
| |
Process
#if
and
#elif
lines with constant expressions.
By default, sections controlled by such lines are passed through unchanged
because they typically start
"#if 0"
and are used as a kind of comment to sketch out future or past development.
It would be rude to strip them out, just as it would be for normal comments.
| |
| |
Modify one or more input files in place.
If an input file is not modified,
the original is preserved instead of being overwritten with an identical copy.
| |
| |
Modify input files in place, and keep backups of the original files by
appending the
backext
to the input filenames.
A zero length
backext
behaves the same as the
| |
| |
Add
#line
directives to the output following any deleted lines,
so that errors produced when compiling the output file correspond to
line numbers in the input file.
| |
| |
Write output to the file
outfile
instead of the standard output when processing a single file.
| |
| |
Instead of processing an input file as usual,
this option causes
unifdef
to produce a list of macros that are used in
preprocessor directive controlling expressions.
| |
| |
Like the
| |
| |
Disables parsing for C strings, comments,
and line continuations,
which is useful
for plain text.
This is a blanket version of the
| |
| |
Print version details.
| |
| |
Set exit status mode to zero, one, or two. See the EXIT STATUS section below for details. | |
The
unifdef
utility takes its input from
stdin
if there are no
file
arguments.
You must use the
The
unifdef
utility works nicely with the
If the exit mode is zero (the default) then unifdef exits with status 0 if the output is an exact copy of the input, or with status 1 if the output differs.
If the exit mode is one, unifdef exits with status 1 if the output is unmodified or 0 if it differs.
If the exit mode is two, unifdef exits with status zero in both cases.
In all exit modes, unifdef exits with status 2 if there is an error.
The exit status is 0 if the
EOF in comment | |
Inappropriate #elif, #else or #endif | |
Missing macro name in #define or #undef | |
Obfuscated preprocessor control line | |
Premature EOF (with the line number of the most recent unterminated #if) | |
Too many levels of nesting | |
Unrecognized preprocessor directive | |
Unterminated char or string literal | |
Character constants are not evaluated.
String literals and character constants in
Handling one line at a time means preprocessor directives split across more than one physical line (because of comments or backslash-newline) cannot be handled in every situation.
Trigraphs are not recognized.
There is no support for macros with different definitions at different points in the source file.
The text-mode and ignore functionality does not correspond to modern cpp(1) behaviour.
UNIFDEF (1) | December 3, 2015 |
Main index | Section 1 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | The most horrifying thing about Unix is that, no matter how many times you hit yourself over the head with it, you never quite manage to lose consciousness. It just goes on and on. | ” |
— Patrick Sobalvarro |