Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-11-07 05:21:50


Hi Merrill,

> Given this program fragment (based on the Getting Started example) using
> Boost::program_options compiled with MinGW:
>
> options_description desc("Program options");
> ...
> variables_map vm;
> store(parse_command_line(argc, argv, desc), vm);

Please always provide a complete program! The snippet copied from docs is
likely to be correct, the problem might be in outside code that you did not
provide.

> gave the following error (reformatted for readability):
>
> error: no matching function for call to
> `store(boost::program_options::basic_parsed_options<const char>,
> boost::program_options::variables_map&)'
>
> candidates are:
> store(const boost::program_options::basic_parsed_options<char>&,
> boost::program_options::variables_map&, bool)
>
> store(const
> boost::program_options::basic_parsed_options<wchar_t>&,
> boost::program_options::variables_map&)
>
> I can add a "true" as a third argument to store(), but the mismatch still
> remains in the first argument: <const char> versus <char>&.
>
> If I assigned the result of parse_command_line() to an intermediate
> variable, I can match the &, but the const char versus char still remains.
>
> What is the problem way of calling store()?

How is you main declared? The C++ standard say it should be

  int main(int ac, char* av[])

Note: "char", not "const char". This is the most likely problem.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net