title: How to find the name of the current function at runtime?
body: <p>After years of using the big ugly MFC ASSERT macro, I have finally decided to ditch it and create the ultimate ASSERT macro.</p>
  
  <p>I am fine with getting the file and line number, and even the expression that failed. I can display a messagebox with these in, and Abort/Retry/Cancel buttons.</p>
  
  <p>And when I press Retry the VS debugger jumps to the line containing the ASSERT call (as opposed to the disassembly somewhere like some other ASSERT functions). So it's all pretty much working.</p>
  
  <p>But what would be really cool would be to <em>display the name of the function that failed</em>.</p>
  
  <p>Then I can decide whether to debug it without trying to guess what function it's in from the filename.</p>
  
  <p>e.g. if I have the following function:</p>
  
  <pre><code>int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  {
     ASSERT(lpCreateStruct-&gt;cx &gt; 0);
     ...
  }
  </code></pre>
  
  <p>Then when the ASSERT fires, the messagebox would show something like:</p>
  
  <pre><code>Function = CMainFrame::OnCreate
  </code></pre>
  
  <p><strong>So, what's the simplest way of finding out the current function name, at runtime?</strong></p>
  
  <p><em>It should not use MFC or the .NET framework, even though I do use both of these.<br>
  It should be as portable as possible.</em></p>