Next: gcd: greatest common divisor, Previous: Quoting, Up: Particular Modules [Contents][Index]
Gnulib has two modules for retrieving the name of the currently executing
program: progname
and getprogname
.
The progname
module defines a variable program_name
.
It contains the name of the currently executing program, on all platforms.
But it cannot be used implicitly: It requires that every main
function be modified to invoke set_program_name (argv[0])
as one
of its first actions.
The getprogname
module defines a function getprogname()
.
It returns the name of the currently executing program, on most platforms.
The advantage of this module is that it can be used without prior
initializations. But it has limitations: In some rare situations, it
cannot determine the name; then it returns "?"
instead. And on
some platforms, it returns a truncated program name.
The error
function uses the getprogname
module.