|
Multiple declaration of a variable? Compile error I can't figure out |
Durnus
Member #7,997
November 2006
|
multiple definition of `particle' Those are the compile errors of my program. It doesn't tell me where the declarations, and when I do a "find" for the declaration, I only find one declaration, and that is in the header file. Don't complain about the code, the main file was written by my little file. character.h
character.cpp:
main.cpp: (Written by little brother)
I can't figure it out, let's see if you all can.
|
Christopher Webb
Member #8,059
December 2006
|
It's because you put "int particle[640][480];" in the header, so it's instantiating in every .c/.cpp file. Put itin one of the .c files, and put extern int particle[640][480]; in the header. |
TeamTerradactyl
Member #7,733
September 2006
|
Christopher's suggestion is correct. I guess I've just never really use constants that way before... Putting extern int particle[640][480]; in the header file and int particle[640][480]; in either main.cpp or character.cpp seems to fix this.
|
Durnus
Member #7,997
November 2006
|
Hmm, thanks. I've gotta remember this for my next programs too.
|
LennyLen
Member #5,313
December 2004
|
Quote: Hmm, thanks. I've gotta remember this for my next programs too. Um, that's exactly what I told you to do in the other thread.
|
|