Usage messages

Both QNX 4 and QNX Neutrino let an executable have a built-in usage message—just a short reminder of the command-line options and some notes on what the executable does.

You can try this out right now at a command-line—type use cat to get information about the cat command. You'll see the following:

cat - concatenate and print files (POSIX)

cat [-cu] [file...]
 -c      Compress, do not display empty lines.
 -u      Unbuffered, for interactive use.
 -n      Print line numbers without restarting.
 -r      Print line numbers restarting count for each file.

You can add these messages into your own executables. My standard mkmain script generates the Makefile and main.use files required for this.

Note: With QNX 4 it was possible to have the usage message embedded within a C source file, typically main.c.

This doesn't work the same way under QNX Neutrino. For example, if the usage message has a line containing an odd number of single-quote characters ('), the compiler gives you grief, even though the offending line is walled-off in an #ifdef section. The solution was to move the usage message out of main.c and into a separate file (usually main.use). To maintain the usage message within the C code, you can get around this by putting the usage message in comments first, and then using the #ifdef for the usage message:

#ifdef __USAGE
%C A utility that's using a single quote

It's an ANSI C compiler thing. :-)