<p>Say you want to generate a matched list of identifiers and strings</p>

<pre><code>enum
{
NAME_ONE,
NAME_TWO,
NAME_THREE
};

myFunction(NAME_ONE, "NAME_ONE");
myFunction(NAME_TWO, "NAME_TWO");
myFunction(NAME_THREE, "NAME_THREE");
</code></pre>

<p>..without repeating yourself, and without auto-generating the code, using C/C++ macros</p>

<p><b>Initial guess:</b></p>

<p>You could add an #include file containing</p>

<pre><code>myDefine(NAME_ONE)
myDefine(NAME_TWO)
myDefine(NAME_THREE)
</code></pre>

<p>Then use it twice like:</p>

<pre><code>#define myDefine(a) a,
enum {
#include "definitions"
}
#undef myDefine

#define myDefine(a) myFunc(a, "a");
#include "definitions"
#undef myDefine
</code></pre>

<p>but #define doesn't let you put parameters within a string?</p>

For your second #define, you need to use the # preprocessor operator, like this:
```
```
#define myDefine(a) myFunc(a, #a);
```
```
That converts the argument to a string.