delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:to:from:subject:date:message-id:references | |
:mime-version:content-type:content-transfer-encoding; q=dns; s= | |
default; b=L/sgD75xqOxKAvAmVyAYbWc0Amwrd7/HCjAWop6sZDFrMtd5n4UcC | |
Wj03S6LcSbHp6T0Kv6WLgukVjxwHbqBouf3OZvWcVrcKOWI/E8POOLcOdQscEHM6 | |
0NUSNhgaO53BjYglMlyN74nq348/1JBV1cU+efgXyeXX4gRg/DYSHc= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:to:from:subject:date:message-id:references | |
:mime-version:content-type:content-transfer-encoding; s=default; | |
bh=gwQKj4TtY3HNzRheqk1SRIAu1eU=; b=SC4BnwGp0m6djhGobVzLLDm8fk74 | |
3pLzWn+tM/SMV09Xm6WC1ftJ/BsWux4frIHBGV8DydaBsPeEbqgPX5vv1QbRZ4wy | |
bGeY00MgonN+NMzOEjU42+59CUiSAxF6RXzuyf1RiLFyZrYTurerohg9KQ+n8J6d | |
r2IVyGxVCnLDBCY= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
X-Spam-SWARE-Status: | No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 |
To: | cygwin AT cygwin DOT com |
From: | Andrew Schulman <schulman DOT andrew AT epa DOT gov> |
Subject: | Re: libargp: argp_program_version does not work |
Date: | Thu, 11 Jul 2013 16:28:26 -0400 |
Lines: | 60 |
Message-ID: | <4q4ut8had25hqmo8b0752i8asuv6ism2qh@4ax.com> |
References: | <000001ce7e08$2b866830$82933890$%fedin AT samsung DOT com> <u4ett8due4p6h9ku1iumscvulp0g688tgk AT 4ax DOT com> |
Mime-Version: | 1.0 |
X-Archive: | encrypt |
> > Hello! > > > > I have found a problem: argp_program_version string is ignored by libargp. > > Hi Pavel. Thanks for reporting this. I confirm your observation. For > example, when I compile argp's example #2 > (http://www.gnu.org/software/libc/manual/html_node/Argp-Example-2.html#Argp-Example-2), > the --version option doesn't work. > > > I guess the problem happens because of DLL's nature. DLLs cannot contain > > unresolved symbols, so the DLL has own version of argp_program_version which > > is always initialized to NULL. There's no way to override it. > > Also confirmed. argp.h declares argp_program_version as > > extern const char *argp_program_version; > > But gllib/argp-pv.c initializes it as > > const char *argp_program_version = (const char *) 0 > > Whether there's a way to override that value by one declared in the user's > code, I don't know. Maybe a linker switch? OK, I remembered how this works. To override the initial values in your program, you just have to reassign them at run time. Here's how it's done with argp's example #2. Note the first two lines of main(), which aren't present in the upstream example. /*** Begin modified argp example #2 ***/ #include <argp.h> const char version[] = "argp-ex2 1.0"; const char bug_address[] = "<bug-gnu-utils AT gnu DOT org>"; /* Program documentation. */ static char doc[] = "Argp example #2 -- a pretty minimal program using argp"; static struct argp argp = { 0, 0, 0, doc }; int main (int argc, char **argv) { argp_program_version = version; argp_program_bug_address = bug_address; argp_parse (&argp, argc, argv, 0, 0, 0); } /*** End modified argp example #2 ***/ If you compile the above version, you'll see that the --version option and bug tracker text are available. I'm sure this problem is familiar to developers and users of shared libraries, but I had forgotten it. I'll add a note to the Cygwin README file, to help all of us remember it next time. Andrew -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |