|
Boost Users : |
Subject: Re: [Boost-users] program_options: Make PO not eat argc
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2014-10-08 04:43:24
On 10/08/2014 10:54 AM, Florian Lindner wrote:
> Hello,
>
> I have a couple of libraries (MPI, petsc) that also consume my applications
> argc and argv, which is parsed with boost::program_options before.
>
> po seems to eat up argv, i.e. removes all items that it handles. Can I
> disable that behavior somehow so that po does not touch argc/argv. Or do I
> need to recreate it, e.g. using collect_unrecognized?
Florian,
this is not expected. Here's the code for parsing:
cmdline::cmdline(int argc, const char*const * argv)
{
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
vector<string> args;
copy(argv+1, argv+argc+!argc, inserter(args, args.end()));
init(args);
#else
init(vector<string>(argv+1, argv+argc+!argc));
#endif
}
So the argc/argv is immediately converted into vector, which is parsed. Can you reproduce this
problem in a simple example?
- Volodya
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net