Error when forward declaring a struct: "has a previous declaration here"
<p>When building my small C++ project, I get the following 2 errors, can't figure out the cause: </p>

<ul>
<li><p>error: using typedef-name 'TTF_Font' after 'struct'.<br>
Points to the following line of code: <code>struct TTF_Font;</code> in Foo.h.  </p></li>
<li><p>error: 'TTF_Font' has a previous declaration here.<br>
Points to the following line of code: <code>typedef struct _TTF_Font TTF_Font;</code> in SDL_ttf.h.</p></li>
</ul>

<p>I've narrowed it down to the following files in a new test project:  </p>

<p>Foo.h:</p>

<pre><code>#ifndef FOO_H
#define FOO_H

struct TTF_Font;

class Foo
{
    TTF_Font* font;
};

#endif // FOO_H
</code></pre>

<p>Foo.cpp:</p>

<pre><code>#include "Foo.h"
#include "SDL/SDL_ttf.h"

// No implementation, just testing
</code></pre>

<p>Main.cpp:</p>

<pre><code>#include "Foo.h"
int main(int argc, const char* argv[])
{
    Foo a;
    return 0;
}
</code></pre>

<p>Do you guys know what I'm doing wrong?</p>

<p>My goal is to forward declare TTF_Font, so I can use it in my header file without including the SDL_ttf header file. I read that including header files in other header files was kinda bad practice, so I switched to forward declarations. All my other forward declarations work fine except this single struct.</p>

<p>When I replace the forward declaration <code>struct TTF_Font;</code> with the header include <code>#include "SDL/SDL.ttf.h"</code>, it compiles without errors. So I can use that, but I want to know WHY, dammit :-).</p>

<p>Extra info: I'm using the Code::Blocks IDE with mingw32 compiler. Project uses the SDL graphics library. Not much C++ experience yet, come from C# background.</p>
