Ich versuche, Befehlszeile mit Boost 1.58.0 zu analysieren. Mein Code ist ziemlich einfach und kopiert \ pasted von den Tutorien. Es sieht wie folgt aus:Boost: unerkannte Option für Positionsargument
try {
po::options_description desc;
desc.add_options()
("version,v", "Display version of application.");
po::positional_options_description p;
p.add("input-file", -1);
try
{
po::store(po::command_line_parser(argc, argv).
options(desc).positional(p).run(), vm);
if (vm.count("version") )
{
std::cout << "Program version: " << SHUF_T_VERSION << std::endl << "Boost library version: " << BOOST_LIB_VERSION << std::endl;
return false;
}
po::notify(vm); // throws on error, so do after help in case
// there are any problems
}
catch(po::error& e)
{
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
std::cerr << desc << std::endl;
return false;
}
}
catch(std::exception& e)
{
std::cerr << "Unhandled Exception: "
<< e.what() << ", application will now exit" << std::endl;
return false;
}
return true;
Der gesamte Code ist here. Der Code scheint korrekt zu sein. Die app -v
wird korrekt verarbeitet. Aber wenn ich irgendein Positionsargument einschließe, wie app myfile
wirft die po::store()
unrecognised option 'myfile'
. Irgendwelche Ideen darüber, warum dies geschieht?