[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: argp: no --version
From: |
Andrew Schulman |
Subject: |
Re: argp: no --version |
Date: |
Thu, 22 Sep 2011 21:12:12 -0400 |
> On 09/22/2011 03:18 AM, Andrew Schulman wrote:
> > So far, so good. But now when I build, for example, Argp example #2
> > against it, it works but there's no --version option:
> >
> > $ ./argpex2 --help
> > Usage: argpex2 [OPTION...]
> > Argp example #2 -- a pretty minimal program using argp
> >
> > -?, --help give this help list
> > --usage give a short usage message
>
> This sounds somewhat similar to this earlier report:
> https://lists.gnu.org/archive/html/bug-gnulib/2009-09/msg00287.html
> although that has been patched (commit 8072fb77), so I don't know what
> to say except that stepping through the example in a debugger may help
> determine what is going wrong.
I understand at least part of what's going wrong.
If I set argp_program_version and argp_program_bug_address as globals, as
in argp-ex2.c:
#include <argp.h>
const char *argp_program_version = "argp-ex2 1.0";
const char *argp_program_bug_address = "<address@hidden>";
int main(int argc, char **argv) {
argp_parse(...);
}
then they have no effect. But if I set them as locals:
#include <argp.h>
int main(int argc, char **argv) {
argp_program_version = "argp-ex2 1.0";
argp_program_bug_address = "<address@hidden>";
argp_parse(...);
}
then they work as desired - I get the --version option and bug reporting
email address.
argp sets default (empty) values of argp_program_version (in argp-pv.c) and
argp_program_bug_address (in argp-ba.c). If I set them again as globals,
then they've been defined twice, which should be an error, if I remember my
C correctly, but I guess the compiler doesn't catch it because the first
definition is in a shared library.
Anyway, since argp sets defaults for those two variables, I wonder if the
documentation and examples should be updated to show that they now have to
be set as locals? (Sorry if the rust on my C knowledge is showing.)
Andrew.