Automatic C++ enum to string mapping macro
I agree with the comments: macros are a mess. Avoid them when possible.

If you're willing to make certain sacrifices (a little repetition), it's possible to avoid macros here. Doing so will also avoid some of the arbitrary limitations in your macro implementation, such as the 10 or so cap on enum values.

Using C++11, it's not hard to wire up Loki Astari's approach to operator&lt;&lt; and operator&gt;&gt; with some type traits template metaprogramming. I personally think enums are much cleaner with the strongly typed enum class ... variant introduced by C++11, so I would suggest that anyway, but the enum_serializable approach I show here works on both strongly and weakly typed enums.

#include &lt;type_traits&gt;
#include &lt;iostream&gt;
#include &lt;https://codereview.stackexchange.com/a/14315/507 by reference&gt;

template &lt;typename Enum&gt;
struct enum_serializable : std::false_type
{};

// enable operator&lt;&lt; and operator&gt;&gt; for `Essai` values
template &lt;&gt;
struct enum_serializable&lt;Essai&gt; : std::true_type
{};

template &lt;typename Enum&gt;
typename std::enable_if&lt;enum_serializable&lt;Enum&gt;::value, std::ostream&amp;
&gt;::type operator&lt;&lt;(std::ostream&amp; os, Enum e)
{
    return os &lt;&lt; enumToString(e);
}

template &lt;typename Enum&gt;
typename std::enable_if&lt;enum_serializable&lt;Enum&gt;::value, std::istream&amp;
&gt;::type operator&gt;&gt;(std::istream&amp; is, Enum&amp; e)
{
    return is &gt;&gt; enumFromString(e);
}


It's also not hard to pull Loki Astari's approach into the operator&lt;&lt; and operator&gt;&gt; functions above, removing the separate enumToString and enumFromString functions and the enumRefHolder and enumConstRefHolder structs entirely.

This general approach should be available before C++11 as well, but std::enable_if will have to be implemented instead of #included.