Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include <typeinfo>
#include <cstring>
#include <algorithm>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include <cstdlib>

namespace cmdline{
Expand Down Expand Up @@ -104,11 +106,17 @@ Target lexical_cast(const Source &arg)

static inline std::string demangle(const std::string &name)
{
int status=0;
char *p=abi::__cxa_demangle(name.c_str(), 0, 0, &status);
std::string ret(p);
free(p);
return ret;
#ifdef _MSC_VER
return name;
#elif defined(__GNUC__)
int status = 0;
char* p = abi::__cxa_demangle(name.c_str(), 0, 0, &status);
std::string ret(p);
free(p);
return ret;
#else
#error "Unsupported compiler. Please implement demangle function for this compiler."
#endif
}

template <class T>
Expand Down