Today I ran into the same problem. @TAS's answer set me on the right track, but it still took 20 minutes to miss a finger to figure out the exact syntax for my particular use case.
To ignore unknown parameters, instead:
po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm);
I wrote this:
po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(), vm); po::notify(vm);
Please note that only the middle row is different.
In a nutshell, use commandline_parser() rather than parse_commandline() , with some "dangly bits" (ie .options(desc).allow_unregistered().run() ) attached after the call.
source share