Avoiding duplicate symbols and retaining code in header files
<p>I have a single global helper function which is used by a bunch of macros in a header file.  The intention is to allow the macros to be usable by simply <code>#include</code>'ing the single header (in other words, I'd like to keep the function definition in the header and avoid putting it in a separate compilation unit).  However, this causes problems when an application <code>#include</code>'s this file in more than one compilation unit, as the duplicate symbols problem arises.</p>

<p>The helper function has enough characteristics in which it shouldn't be declared inline.</p>

<p>I was messing around and found that using unnamed namespaces solves the problem of duplicate symbols, i.e.:</p>

<pre><code>namespace
{
    void foo(...)
    {
    }
};

#define HELPER_A foo(1, ...);
#define HELPER_B foo(2, ...);
...
</code></pre>

<p>Is there any downside to this approach?  Are there better alternatives?</p>
