need a workaround for a "multiple definition" error
<p>A toy code illustrating my problem is as follows:</p>

<p>stuff.h:</p>

<pre><code>#ifndef STUFF
#define STUFF

int a;
int testarr[]={1,2,3};

#endif
</code></pre>

<p>fcn.h:</p>

<pre><code>#include "stuff.h"
int b[]={5,6,7};
void fcn();
</code></pre>

<p>main.h:</p>

<pre><code>#include "stuff.h"
#include &lt;stdio.h&gt;
</code></pre>

<p>fcn.c:</p>

<pre><code>#include "main.h"

void fcn() {
   printf("Hello\n");
}
</code></pre>

<p>main.c:</p>

<pre><code>#include "main.h"
#include "fcn.h"

int main() {
   fcn();
   printf("HI\n");
}
</code></pre>

<p>An attempt to compile fails with:</p>

<pre><code>/g/pe_19976/fcn_2.o:(.data+0x40): multiple definition of `testarr'
/g/pe_19976/main_1.o:(.data+0x40): first defined here
</code></pre>

<p>After doing some reading, I realize that defining the array <code>testarr</code> in the header file is a problem.  But the thing is, in my real code, several files need access to <code>testarr</code> and it needs to have the same assigned values everywhere.  I guess I could put it in <code>main.h</code> (?) but even if that would work, in my real code it logically belongs in <code>stuff.h</code>.  How do I solve this conundrum?</p>

<p>BTW, based on something else I found, I tried defining <code>testarr</code> as <code>extern</code> but got the same problem.</p>