Demangling in MSVC

后端 未结 4 1395
轻奢々
轻奢々 2020-12-16 23:47

How can i demangle name in MSVC? There\'s abi::__cxa_demangle function in gcc. In MSDN i\'ve found UnDecorateSymbolName:

http://msdn.microsoft.com/ru-ru/library/windo

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 00:46

    It seems UndecorateSymbolName/__unDName can't handle function-local names. If you move the class definition to the global scope, .name() will return already demangled name (use .raw_name() to get the mangled name).

    To demangle the (global) raw name manually, you need two changes to your code:

    1) skip the leading period in the mangled name (i.e. start at the '?').
    2) instead of 0, use the flag value 0x2800 (UNDNAME_32_BIT_DECODE | UNDNAME_TYPE_ONLY).

    I found this out from the CRT sources of VS2012:

      if ((pTmpUndName = __unDName(NULL, (this->_M_d_name)+1, 0,
             &_malloc_base, &_free_base, 
             UNDNAME_32_BIT_DECODE | UNDNAME_TYPE_ONLY)) == NULL)
    

提交回复
热议问题