How to implement the DERR_ENTRY macro in Guru of the week #32?
<p>In C++ <a href="http://www.gotw.ca/gotw/032.htm" rel="nofollow">Guru of the week #32</a> (speaking about "legitimate" use of preprocessor macros), the last example shows a macro called <code>DERR_ENTRY</code> without any actual implementation :</p>

<blockquote>
  <p>The implementations of DERR_ENTRY and related macros is left to the reader.</p>
</blockquote>

<p>This macro is supposed to replace this :</p>

<pre><code> // For outsiders:
enum Errors {
  ERR_OK = 0,           // No error
  ERR_INVALID_PARAM = 1 // &lt;description&gt;
  ...
}

// For the module's internal use:
map&lt;Error,const char*&gt; lookup;
lookup.insert( make_pair( Error(0), "No error" ) );
lookup.insert( make_pair( Error(1), "&lt;description&gt;" ) );
</code></pre>

<p>with this : (much simpler)</p>

<pre><code>DERR_ENTRY( ERR_OK,            0, "No error" ),
DERR_ENTRY( ERR_INVALID_PARAM, 1, "&lt;description&gt;" ),
//...
</code></pre>

<p>according to the author of GotW :</p>

<blockquote>
  <p>We'd like to have both representations without defining the actual information (code/msg pairs) twice. With macro magic, we can simply write a list of errors as follows, creating the appropriate structure at compile time</p>
</blockquote>

<p>But I can't see an easy way to define both an enum entry and a map entry at the same time. Or maybe there is unknown syntax I don't know that can solve this ?</p>

<p>So, how would you implement the DERR_ENTRY macro ?</p>

<p>Note : remember that GotW #32 is supposed to illustrate the power of preprocessor macros.</p>
