1 @node progname and getprogname
2 @section progname and getprogname
4 @c Copyright (C) 2007, 2009--2024 Free Software Foundation, Inc.
6 @c Permission is granted to copy, distribute and/or modify this document
7 @c under the terms of the GNU Free Documentation License, Version 1.3 or
8 @c any later version published by the Free Software Foundation; with no
9 @c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
10 @c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.
12 Gnulib has two modules for retrieving the name of the currently executing
13 program: @code{progname} and @code{getprogname}.
17 The @code{progname} module defines a variable @code{program_name}.
18 It contains the name of the currently executing program, on all platforms.
19 But it cannot be used implicitly: It requires that every @code{main}
20 function be modified to invoke @code{set_program_name (argv[0])} as one
25 The @code{getprogname} module defines a function @code{getprogname()}.
26 It returns the name of the currently executing program, on most platforms.
27 The advantage of this module is that it can be used without prior
28 initializations. But it has limitations: In some rare situations, it
29 cannot determine the name; then it returns @code{"?"} instead. And on
30 some platforms, it returns a truncated program name.
33 The @code{error} function uses the @code{getprogname} module.