Errors with a struct.

Hey,

Heres an example of the code i use.

1
2
3
4
5
6
struct PLAYER_STATS
{
     bool bTEST;
};

PLAYER_STATS m_PLAYER;


then i'd do like:

1
2
3
4
void SET_PLAYER_STATS()
{
     m_PLAYER.bTEST = true;
}


I'd compile and get the error;

 
1>stats.obj : error LNK2005: "struct PLAYER_STATS m_PLAYER" (?m_PLAYER@@3UPLAYER_STATS@@A) already defined in gamelimits.obj


Thats the syntax of all my errors, i don't know why I'm getting them :/

Can anyone pinpoint where i am going wrong?

Thanks :)
Last edited on
PLAYER_STATS m_PLAYER;

Is this in a header? If so that may be the problem, it needs to be in a source file, not a header. Why? Because if you include the header it's in into two different source files, the symbol will get included into both of them and declared for both of their output files, and you'll get the error you did, because the symbol exists twice for the linker.
change PLAYER_STATS m_PLAYER; to struct PLAYER_STATS m_PLAYER; and try again
Last edited on
@ stravant:

You fixed my problem, cheers!

@ Skillness:

Thanks for your response, but strvant's answer fixed it.

:)
Topic archived. No new replies allowed.