#include-Problem
-
Hallo,
ich habe 3 Module mit Namen CObject.h,CPhysic.h und static.h !
Ich schreibe jetzt einfach mal den Anfang hierrein.CObject.h
#ifndef __COBJECT__ #define __COBJECT__ #include "global.h" #include "static.h" class CObject { ... } #endif
CPhysic.h
#ifndef __CPHYSIC__ #define __CPHYSIC__ class CPhysic { ... } #endif
static.h
#ifndef __STATIC__ #define __STATIC__ #include "CPhysic.h" CPhysic objPhysic; ... #endif
Dabei kommt immer eine Fehlermeldung für jedes Modul in meinem Projekt:
*.obj : error LNK2005: "class CPhysic objPhysic" (?objPhysic@@3VCPhysic@@A) bereits in CObject.obj definiert
<-- Obwohl ich doch überall #ifndet ... #define ... #endif stehen habe!Wenn ich in der CObject.h das #include "static.h" durch #include "CPhysic.h" ersetze funktioniert alles einwandfrei.
Woran kann das bitte liegen? Ich benutze Visual C++ 6.0Schönen Gruß
Pomplito
-
anstatt
//static.h CPhysic objPhysic;
machs so
//static.h extern CPhysic objPhysic; //static.cpp CPhysic objPhysic;