Santosh Joseph wrote:
Code snippet is below...basically I have 2 options I want to process "host,s" & "help,h". I would like to process options like this: for host: --host, -host, -s for help: --help, -help, -h Maybe I setup the opt_style variable wrong or is this correct behavior? I'm using boost 1.33.1
when i run the program:
po.exe -host localhost -h *** Command line processing error: ambiguous option h
..... int opt_style = (po::command_line_style::unix_style | po::command_line_style::allow_long_disguise | po::command_line_style::allow_slash_for_short); The important points here are that 1. 'unix_style' includes 'allow_guessing' 2. you explicitly specify allow_long_disguise So, when program_options sees '-h' it first tries to parse it as long option, and due to 'allow_guessing' it checks for all long options starting with 'h'. There are two such options, so you get an ambiguity. If we first tried to parse every token as short option, then -help will be parsed as option -h with value 'elp' -- probably not what you want. I'd suggest that you mask out the allow_guessing style option. - Volodya