Hi, I habe a problem with store(parse_config_file(...), ...); I don't know why... That isn't my first program with program_options but it is my first program with parse_command_line and parse_config_file in one. Here is my code. First I parse the command line, second I parse the config file. Is it a very simple script. With my debuger (gdb and ddd) I can see, that the problem is here: bpo::store(bpo::parse_config_file(conf_file, desc_file), vm); (at the "end" from script). vm is global definiert. The Namspace bpo ist boost::program_options I use the gcc 3.3.5 and I compile static with: /usr/local/lib/libboost_program_options-gcc-1_33_1.a My OS is OpenBSD What I make false? My script is at the end. Sorry for my bad english. I thanks for Help, Dear, Pascal Vizeli [cpp] bpo::variables_map vm_cmd; bpo::options_description desc_file("config file"), desc_cmd("command line"); // Make options descriptions desc_cmd.add_options() ("config,c", bpo::value<std::string>(), "The Config file") ("help,h", "produce help message") ; desc_file.add_options() ("port", bpo::value<int>()->default_value(6667), "IRC Server Port") ("server", bpo::value<char *>(), "IRC Server IP") ("nick", bpo::value<std::string>(), "Bot Nick") ("user", bpo::value<std::string>(), "username hostname servername :realname") ("nickserv", bpo::value<std::string>(), "Nickserv Identify string") ("oper-pw", bpo::value<std::string>(), "Oper Password") ("mode", bpo::value<std::string>(), "Mode for Bot") ("logchan", bpo::value<std::string>(), "A #Chan for logs") ("logchan_status", bpo::value<int>(), "Logchan On or Off") ("invite-chan", bpo::value<int>(), "Invite for logchan?") ("invite-command", bpo::value<std::string>(), "Invite Command") ("re-chan", bpo::value<int>(), "Refresh Channellist until SEC") ("logfile", bpo::value<std::string>(), "File for logs") ("chroot", bpo::value<char *>(), "Set the chroot dir (path)") ; // Parse CMD bpo::store(bpo::parse_command_line(argc, argv, desc_cmd), vm_cmd); bpo::notify(vm_cmd); if(vm_cmd.count("help")){ std::cout << desc_cmd << std::endl; std::cout << desc_file << std::endl; exit(0); } if(!vm_cmd.count("config")){ printo_err("Config file not found! Use --help for Infos"); exit(0); } // Open Config file std::ifstream conf_file(vm_cmd["config"].as<std::string>().c_str()); if(conf_file.is_open()){ // Parse Config file bpo::store(bpo::parse_config_file(conf_file, desc_file), vm); // Here is the false say my debuger bpo::notify(vm); }else{ printo_err("can't open the conf file!"); exit(0); } [/cpp]
Pascal Vizeli wrote:
Hi,
I habe a problem with store(parse_config_file(...), ...); I don't know why...
it is my first program with parse_command_line and parse_config_file in one.
Here is my code. First I parse the command line, second I parse the config file. Is it a very simple script.
With my debuger (gdb and ddd) I can see, that the problem is here: bpo::store(bpo::parse_config_file(conf_file, desc_file), vm); (at the "end" from script). vm is global definiert. The Namspace bpo ist boost::program_options
I don't see any try/catch block in your program. Since program_options throws on errors, like underfined option, you should have try/catch block and handle errors there. The 'aborted' you see is most likely a result of uncaught exception. - Volodya
participants (2)
-
Pascal Vizeli
-
Vladimir Prus