#include #include #include #include int main(int argc, char* argv[]) { try { boost::program_options::options_description desc("Allowed options"); desc.add_options() ("help,h", "produce help message") ("enable-debug", "enables debug output.") ; boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); boost::program_options::notify(vm); if (vm.count("help") || (argc == 1)) { std::cout << "To reproduce the bug call " << argv[0] << " --enable-debug --enable-debug" << std::endl << std::endl << " On Windows the option name '--enable-debug' is contained as expected in the error message:" << std::endl << " option '--enable-debug' cannot be specified more than once" << std::endl << std::endl << " On Linux only the last part of the option name '--enable-debug' (=> '--debug') is contained in the error message:" << std::endl << " option '--debug' cannot be specified more than once" << std::endl << std::endl << "Options:" << std::endl; std::cout << desc << std::endl; if (argc > 1) { return 0; } else { return 1; } } if (vm.count("enable-debug")) { std::cout << "Activating debug output." << std::endl; } std::cout << "Program continues" << std::endl; } catch (const std::exception& e) { std::cout << e.what() << std::endl; } return 0; }