
Hi I m using program options classes to handles command line arguments (Boost version 1.35, Debian lenny packages). I don't manage to get this code work : boost::program_options::options_description cmd_line_options_("Command line options") ; boost::program_options::variables_map current_options_ ; int port_ = 0 ; cmd_line_options_.add_options() ("port,p", boost::program_options::value<int>(&port_), "specify the destination port to use") ; try { boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(cmd_line_options_).run(), current_options_) ; } catch(po::error &e) { cout << "Error when parsing command line arguments: " << e.what() << "\n" ; } cout << port_ << ":" << current_options_["port"].as<int>() << endl ; When executing : ./foo --port=12345, the output is : 0:12345 The port_ variable value remains to be 0 when the current_options_ variable hold the right value (12345). Could someone tell me what am I doing wrong ? Thanks