title: Demangling in MSVC
body: <p>How can i demangle name in MSVC? There's abi::__cxa_demangle function in gcc. In MSDN i've found UnDecorateSymbolName:</p>
  <p><a href="http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms681400%28v=vs.85%29.aspx" rel="noreferrer">http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms681400%28v=vs.85%29.aspx</a></p>
  <p>Unfortunately, this function can't undecorate even such symbol:</p>
  <pre><code>#include &lt;Windows.h&gt;
  #include &lt;DbgHelp.h&gt;
  
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;typeinfo&gt;
  
  int main()
  {
      SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
  
      if (!SymInitialize(GetCurrentProcess(), NULL, TRUE))
      {
          std::cout &lt;&lt; &quot;SymInitialize returned error: &quot; &lt;&lt; GetLastError() &lt;&lt; '\n';
          return EXIT_FAILURE;
      }
  
      class Foo {};
      Foo instance;
  
      const char* decorated_name = typeid(instance).name();
      char undecorated_name[1024];
      if (!UnDecorateSymbolName(decorated_name, undecorated_name, sizeof(undecorated_name) / sizeof(*undecorated_name), UNDNAME_COMPLETE))
      {
          std::cout &lt;&lt; &quot;UnDecorateSymbolName returned error: &quot; &lt;&lt; GetLastError() &lt;&lt; '\n';
          return EXIT_FAILURE;
      }
  
      std::cout &lt;&lt; &quot;Decorated name: &quot; &lt;&lt; decorated_name &lt;&lt; '\n'
                &lt;&lt; &quot;Undecorated name: &quot; &lt;&lt; undecorated_name &lt;&lt; '\n';
  }
  </code></pre>
  <p><strong>Output</strong></p>
  <blockquote>
  <p>Decorated name: ?AVFoo@?4?main@</p>
  <p>Undecorated name: ?AVFoo@?4?main@</p>
  </blockquote>
  <p>If i am doing it wrong?</p>
  <p>I've heard somewhere about _unDName function, but i can't find any example with it. In which header file it is defined?</p>