cmdline轻量级的C++命令行解析库--windows
cmdline介绍cmdline 是一个非常easy好用的C++命令行解析库,其基于模板。所以使用非常easy,写出的代码也非常优雅。因为其仅仅包括一个头文件。所以非常easy集成到自己的项目中。官网:https://github.com/tanakh/cmdline参考:http://www.mamicode.com/info-detail-1923374.html在window上利用VS编译的
cmdline介绍
cmdline 是一个非常easy好用的C++命令行解析库,其基于模板。所以使用非常easy,写出的代码也非常优雅。
因为其仅仅包括一个头文件。所以非常easy集成到自己的项目中。
官网:https://github.com/tanakh/cmdline
参考:http://www.mamicode.com/info-detail-1923374.html
在window上利用VS编译的时候遇到问题汇总。
错误1 cxxabi.h提示错误
fatal error C1083: 无法打开包括文件:“cxxabi.h”: No such file or directory
需要修改的地方
//当编译器非gcc时,不包含cxxabi.h头文件
#ifdef __GNUC__
#include <cxxabi.h>
#endif
static inline std::string demangle(const std::string &name)
{
#ifdef _MSC_VER
return name; // 为MSVC编译器时直接返回name
#elif defined(__GNUC__)
// 为gcc编译器时还调用原来的代码
int status=0;
char *p=abi::__cxa_demangle(name.c_str(), 0, 0, &status);
std::string ret(p);
free(p);
return ret;
#else
// 其他不支持的编译器需要自己实现这个方法
#error unexpected c complier (msc/gcc), Need to implement this method for demangle
#endif
}
参考https://github.com/tanakh/cmdline/issues/6
错误2 std::max使用的位置错误
error C2589: '(' : illegal token on right side of '::'
error C2143: syntax error : missing ';' before '::'
解决方式(两种)修改如下面
max_width = (std::max)(max_width, (ordered[i]->name().length()));
max_width=std::max< size_t>(max_width, ordered[i]->name().length());
参考 https://github.com/tanakh/cmdline/issues/13
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)