title: Any utility to test expand C/C++ #define macros?
body: <p>It seems I often spend way too much time trying to get a #define macro to do exactly what i want. I'll post my current dilemma below and any help is appreciated. But really the bigger question is whether there is any utility someone could recommend, to quickly display what a macro is actually doing? It seems like even the slow trial and error process would go much faster if I could see what is wrong.</p>
  
  <p>Currently, I'm dynamically loading a long list of functions from a DLL I made. The way I've set things up, the function pointers have the same nanes as the exported functions, and the typedef(s) used to prototype them have the same names, but with a prepended underscore. So I want to use a define to simplify assignments of a long long list of function pointers.</p>
  
  <p>For example, In the code statement below, 'hexdump' is the name of a typedef'd function point, and is also the name of the function, while _hexdump is the name of the typedef. If GetProcAddress() fails, a failure counter in incremented. </p>
  
  <pre><code>if (!(hexdump = (_hexdump)GetProcAddress(h, "hexdump"))) --iFail;
  </code></pre>
  
  <p>So let's say I'd like to replace each line like the above with a macro, like this...</p>
  
  <pre><code>GETADDR_FOR(hexdump )
  </code></pre>
  
  <p>Well this is the best I've come up with so far. It doesn't work (my // comment is just to prevent text formatting in the message)...</p>
  
  <pre><code>// #define GETADDR_FOR(a) if (!(a = (#_#a)GetProcAddress(h, "/""#a"/""))) --iFail; 
  </code></pre>
  
  <p>And again, while I'd APPRECIATE an insight into what silly mistake I've made, it would make my day to have a utility that would show me the error of my ways, by simply plugging in my macro.</p>