There are a few common global variables that I use in most of my projects:
- version
- This pointer to a character string contains the version string.
By convention, the version is always five characters — A.BCDE,
with A being the major version number, and BCDE
being the build number.
The version is the only thing that's stored in the version.c
file.
- progname
- A pointer to a character string containing the name of the program.
(This is an old convention of mine; Neutrino now has the __progname variable as well.)
- blankname
- A pointer to a character string the same length as progname, filled with blank characters
(it gets used in multi-line messages).
I strive to have all messages printed from every utility include the
progname variable.
This is useful if you're running a bunch of utilities and redirecting their output to a common
log file or the console.
You'll often see code like this in my programs:
fprintf (stderr, "%s: error message...\n", progname, ...);