MSVC编译cmdline

解决办法

1.修改#include部分

1
2
3
4
//当编译器非gcc时,不包含cxxabi.h头文件
#ifdef __GNUC__
#include <cxxabi.h>
#endif

2.修改demangle函数,当编译器为MSVC时直接将输入参数返回

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
}