unifdef(1) on Solnix vs Linux and the BSDs
On Solnix, unifdef is the illumos /usr/bin/unifdef, an older and much smaller program than the FreeBSD and OpenBSD unifdef. It supports only -c, -l, -t, -D, -U, -iD and -iU, and its -l does what -b does on the BSDs. When a symbol is given more than once, the first one wins; on the BSDs the last one wins.
The manual pages
- Solnix: unifdef(1) from
pkgs.solnix.illumos-world-man· illumos.org - FreeBSD: unifdef(1) 15.1-RELEASE
- OpenBSD: unifdef(1) 8.0
What Solnix runs
A default Solnix system runs the illumos unifdef at /usr/bin/unifdef. No other variants are shipped. The page is published by pkgs.solnix.illumos-world-man. The Solnix page documents no -f, -k, -s, -m, -M, -o, -n, -b, -B, -h, -V or -x options.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| FreeBSD, OpenBSD | blanking removed lines (-l vs -b) | Solnix replaces removed lines with blank lines using -l. FreeBSD and OpenBSD use -b for this. The BSD pages do not document -l, and the Solnix page does not document -b. Scripts need different flags on each.Source: Solnix unifdef(1) -l; FreeBSD unifdef(1) -b; OpenBSD unifdef(1) -b |
| FreeBSD, OpenBSD | repeated symbols | On Solnix, if the same symbol appears in more than one argument, only the first occurrence counts. On FreeBSD and OpenBSD, the last occurrence dominates, and later -f and -D/-U options override earlier ones. Reordering arguments gives different results.Source: Solnix unifdef(1) DESCRIPTION (only the first occurrence is significant); FreeBSD unifdef(1) -Usym, -f; OpenBSD unifdef(1) -D, -U, -f |
| FreeBSD, OpenBSD | defining a value (-Dsym=val) | The Solnix synopsis shows only -Dname and -Uname, with no =val form. FreeBSD and OpenBSD accept -Dsym=val, and -Dsym alone defines the macro as 1. Without a value, the Solnix page does not say what the symbol is defined as.Source: Solnix unifdef(1) SYNOPSIS, -Dname; FreeBSD unifdef(1) -Dsym=val, -Dsym; OpenBSD unifdef(1) -Dsym[=val] |
| FreeBSD, OpenBSD | #if and #elif expressions | FreeBSD and OpenBSD evaluate #if and #elif control expressions (defined(), comparison and logical operators) when -D/-U give enough information. Constant expressions such as #if 0 are skipped unless -k is given. The Solnix page describes only ifdef, ifndef, else and endif lines, and has no -k.Source: Solnix unifdef(1) DESCRIPTION; FreeBSD unifdef(1) DESCRIPTION, -k; OpenBSD unifdef(1) DESCRIPTION, -k |
| FreeBSD, OpenBSD | nested ifdefs of the same kind | Solnix states that an ifdefX nested inside another ifdefX is treated as an unrecognized symbol. The visible FreeBSD and OpenBSD text has no such rule. Nested conditionals on the same symbol may be left in the output on Solnix. Source: Solnix unifdef(1) DESCRIPTION (third paragraph); FreeBSD unifdef(1) DESCRIPTION; OpenBSD unifdef(1) DESCRIPTION |
| FreeBSD, OpenBSD | in-place editing and output file | Solnix writes only to standard output and reads one filename or standard input. FreeBSD and OpenBSD have -m (edit in place), -M backext (edit in place with backups) and -o outfile. FreeBSD also accepts several input files. Solnix scripts must redirect output.Source: Solnix unifdef(1) SYNOPSIS, DESCRIPTION (last paragraph); FreeBSD unifdef(1) -m, -M, -o; OpenBSD unifdef(1) -m, -M, -o |
| FreeBSD, OpenBSD | symbol file and symbol listing | FreeBSD and OpenBSD can read #define and #undef lines from a file with -f, and list controlling macros with -s (and -S for nesting depth on OpenBSD). The Solnix page has none of these options.Source: FreeBSD unifdef(1) -f, unifdefall; OpenBSD unifdef(1) -f, -s, -S; Solnix unifdef(1) SYNOPSIS |
| FreeBSD, OpenBSD | -i option wording | Solnix -iDname and -iUname 'ignore, but print out' lines under the named symbol, so unifdef does not parse quotes and comments in them. FreeBSD and OpenBSD describe the same purpose, but take -iDsym[=val]. FreeBSD and OpenBSD say these options affect C strings, comments and line continuations.Source: Solnix unifdef(1) -iDname, -iUname; FreeBSD unifdef(1) -iDsym; OpenBSD unifdef(1) -iDsym |
| FreeBSD, OpenBSD | other BSD-only options | FreeBSD and OpenBSD add -B (compress blank lines), -n (emit #line directives), -e (ignore multi-line directives instead of erroring), -d, -h, -K and -V. FreeBSD also has -x, and ships a unifdefall script. The Solnix page documents none of these.Source: FreeBSD unifdef(1) SYNOPSIS, -B, -n, -e, unifdefall; OpenBSD unifdef(1) -B, -n, -e, -K, -V; Solnix unifdef(1) SYNOPSIS |
| FreeBSD, OpenBSD | unchanged options | -c (complement) and -t (plain text: no parsing of comments or quotes) are documented on all three systems. The FreeBSD and OpenBSD pages say -t also covers line continuations; the Solnix page mentions only comments and quotes.Source: Solnix unifdef(1) -c, -t; FreeBSD unifdef(1) -c; OpenBSD unifdef(1) -c, -t |
Standards
- POSIX: unifdef is not a POSIX.1-2024 utility.
Writing portable scripts
- Pass only
-D,-U,-cand-tif the script must also run on Solnix. Do not rely on-Dsym=val,-f,-k,-mor-o. Redirect stdout to a file instead. - Do not depend on which duplicate
-D/-U wins. Solnix keeps the first occurrence, FreeBSD and OpenBSD keep the last.
Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.