c++ - 在 Visual Studio MSVC 14.0 断言下使用 boost 程序选项失败

标签 c++ boost boost-program-options

我在 MSVC 14.0 下编译了 Boost 1.66。我正在尝试将在 Linux 上的 Boost 下运行良好的现有项目移植到 Visual Studio。

那是失败的代码:

options.add_options()
            ("help", "Produce help message")
            ("config-file,c", po::value<string>(&config_file_path)->default_value("config.xml"), "Configuration file path")
            ("port,p", po::value<int>(&html_port)->default_value(7999), "HTTP Server port")
            ("html_root,hr", po::value<string>(&html_root)->default_value("."), "Directory root for HTML page");

使用以下断言:

Assertion failed: n == name.size()-2, file libs\program_options\src\options_description.cpp, line 177

有什么建议吗?

最佳答案

我认为选项短名称(逗号后)应该是单个字符,即 ,hr" 应该是 ,r"

关于c++ - 在 Visual Studio MSVC 14.0 断言下使用 boost 程序选项失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50985759/

相关文章:

c++ - #include <boost/chrono.hpp> 导致无法解析的外部符号,使用了 bcp

c++ - 在 Visual Studio 2008 上使用 jsoncpp

c++ - 编译错误:boost::promise<T>::set_value(const T&) 不存在

C++ SSL 虚拟主机

c++ - boost::program_options 忽略配置文件中的选项

C++ 查找指针错误

c++ - _strset_s 崩溃

c++ - BOOST 程序_选项 : parsing multiple argument list

c++ - boost:如何按名称查找进程的进程ID?

c++ - boost 程序选项和验证功能