cmdline轻量级的C++命令行解析库--windows

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值