Moving a String Array Definition from Main to Another File
<p>I'm writing a game, and right now I'm trying to break up the one file I have into multiple for the sake of organization. I've run into a problem I'm not quite sure how to fix however. Initially, I had a map defined in main like this:</p>

<pre><code>char const *map[]={
    " ------------- ",
    "|......|......|",
    "|.............|",
    "|......---.---|",
    "|---.---...|..|",
    "|..........|..|",
    "|..........|..|",
    "|.............|",
    "|..........|..|",
    " ------------- ",
};
</code></pre>

<p>This was working fine. Now I have moved a declaration into a file called "map.h":</p>

<pre><code>extern const char *map[];
</code></pre>

<p>And the actual definition in a file called "map.c":</p>

<pre><code>#include "map.h"
*map = {
    " ------------- ",
    "|......|......|",
    "|.............|",
    "|......---.---|",
    "|---.---...|..|",
    "|..........|..|",
    "|..........|..|",
    "|.............|",
    "|..........|..|",
    " ------------- ",
};
</code></pre>

<p>This gives me an error: "conflicting types for map"</p>

<p>As well as numerous warnings: "initialization from incompatible pointer type [-Wincompatible-pointer-types] " ------------- ""</p>

<p>and: "excess elements in scalar initializer" for each row after that.</p>

<p>If I remove the dereference operator in fron of "map" in map.c, then it gives me "initializer element is not computable at load time".
I then thought I could get around this by just defining the array in map.h, but of course this then gives me errors for multiple definitions for each file I include map.h in.</p>

<p>Does anyone know of a way to implement this/what I am doing wrong?</p>

<p>Thanks, Nic</p>