Section: User Commands (1)
Return to Main Contents
unifdef , unifdefall
- remove preprocessor conditionals from code
[-D sym [= val
[-iD sym [= val
utility selectively processes conditional
It removes from a file
both the directives
and any additional text that they specify should be removed,
while otherwise leaving the file alone.
utility acts on
#if , #ifdef , #ifndef , #elif , #else
and it understands only the commonly-used subset
of the expression syntax for
integer values of symbols defined on the command line,
operator applied to symbols defined or undefined on the command line,
! , < , > , <= , >= , == , != , && , ||
and parenthesized expressions.
Anything that it does not understand is passed through unharmed.
It only processes
directives if the symbol is specified on the command line,
otherwise they are also passed through unchanged.
By default, it ignores
lines with constant expressions,
or they may be processed by specifying the
flag on the command line.
utility also understands just enough about C
to know when one of the directives is inactive
because it is inside
or affected by a backslash-continued line.
It spots unusually-formatted preprocessor directives
and knows when the layout is too odd to handle.
A script called
can be used to remove all conditional
directives from a file.
to get lists of all the controlling symbols
and their definitions (or lack thereof),
with appropriate arguments to process the file.
- -D sym [= val
Specify that a symbol is defined,
and optionally specify what value to give it
for the purpose of handling
- -U sym
Specify that a symbol is undefined.
If the same symbol appears in more than one argument,
the last occurrence dominates.
flag is specified,
then the operation of
i.e., the lines that would have been removed or blanked
are retained and vice versa.
Turn on printing of degugging messages.
processes its input one line at a time,
it cannot remove preprocessor directives that span more than one line.
The most common example of this is a directive with a multi-line
comment hanging off its right hand end.
has to process such a directive,
it will complain that the line is too obfuscated.
option changes the behaviour so that,
such lines are left unprocessed instead of reporting an error.
lines with constant expressions.
By default, sections controlled by such lines are passed through unchanged
because they typically start
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.
Replace removed lines with blank lines
instead of deleting them.
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.
Instead of processing the input file as usual,
this option causes
to produce a list of symbols that appear in expressions
It is useful in conjunction with the
Disables parsing for C comments
and line continuations,
which is useful
for plain text.
- -iD sym [= val
- -iU sym
If your C code uses
to delimit non-C lines,
such as comments
or code which is under construction,
then you must tell
which symbols are used for that purpose so that it will not try to parse
and line continuations
One specifies ignored symbols with
-iD sym [= val ]
-D sym [= val
- -I path
an additional place to look for
This option is ignored by
for compatibility with
and to simplify the implementation of
utility copies its output to
and will take its input from
argument is given.
utility works nicely with the
utility exits 0 if the output is an exact copy of the input,
1 if not, and 2 if in trouble.
- Too many levels of nesting.
- Obfuscated preprocessor control line.
(with the line number of the most recent unterminated
command appeared in
support was added in
Fx 4.7 .
Expression evaluation is very limited.
Preprocessor control lines 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 symbols with different definitions at
different points in the source file.
The text-mode and ignore functionality does not correspond to modern
- EXIT STATUS
- SEE ALSO
linux.jgfs.net manual pages