Gnulib provides a few modules for printing --version
and
bug-reporting information according to the GNU Coding Standards; see
https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion
The ‘version-etc’ module defines functions used to emit
--version
and bug-reporting input in a standard way. The module
expects the string version_etc_copyright
to be defined to display
the copyright holder along with the package release year. The
version_etc
function can then be used like so:
const char version_etc_copyright[] = "Copyright %s %d copyright-holder"; int main (void) { version_etc (stdout, "my-program", "my-package", "1.0", "author1", "author2", (const char *) NULL); return 0; }
The above example generates the following output:
my-program (my-package) 1.0 Copyright (C) 2025 copyright-holder License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by author1 and author2.
The ‘version-etc’ module also defines the function
emit_bug_reporting_address
which emits the bug-reporting location
based on arguments passed to AC_INIT
. For example, using the
following in configure.ac:
AC_INIT([gnulib], [0.0], [[email protected]], [gnulib], [https://www.gnu.org/software/gnulib/])
And the following program:
#include <config.h> #include "version-etc.h" int main (void) { emit_bug_reporting_address (); return 0; }
Will output:
Report bugs to: [email protected] gnulib home page: <https://www.gnu.org/software/gnulib/> General help using GNU software: <https://www.gnu.org/gethelp/>
The ‘version-etc-fsf’ module defines and links to the variable
version_etc_copyright
containing copyright information for Free
Software Foundation. This module should be used by programs which are
FSF-copyrighted and use the ‘version-etc’ module.
The ‘argp-version-etc’ defines the argp_version_setup
function takes the program name and authors as arguments. This function
should be called before argp_parse
since it modifies argp global
variables; see
https://www.gnu.org/software/libc/manual/html_node/Argp-Global-Variables.html.