2014-02-11 68 views
1

我敢肯定,答案是直視我的臉,但由於這個原因,我還沒有能夠取得任何進展......首先一些代碼:<功能列表>多重定義

對象/ testObject.h:

#include <irrlicht.h> 
#include "../maths.h" 

using namespace irr; 

#ifndef testObject_H 
#define testObject_H 

class testObject : public scene::SAnimatedMesh 
{ 
    public: 
     testObject(IrrlichtDevice* device); 
     virtual ~testObject(); 
    protected: 
     const char* meshInfoLocation; 
     int totAnims; 
    private: 

}; 

#endif 

對象/ testObject.cpp:

#include "testObject.h" 

testObject::testObject(IrrlichtDevice* device) : scene::SAnimatedMesh() 
{ 
    io::IrrXMLReader* modelInformation = io::createIrrXMLReader(meshInfoLocation); 

    while(modelInformation->read()) 
    { 
     if(modelInformation->getNodeName() == "totAnims") totAnims = stringToInt(modelInformation->getAttributeValue("totAnims")); 
    } 
} 

testObject::~testObject() { } //Incomplete, but should still compile... 

當我編譯THI S碼,我得到以下錯誤:

/home/david/workspace/spaceSim/objects/testObject.cpp||In constructor ‘testObject::testObject(irr::IrrlichtDevice*)’:| 
/home/david/workspace/spaceSim/objects/testObject.cpp|20|warning: comparison with string literal results in unspecified behaviour [-Waddress]| 
/home/david/workspace/spaceSim/main.cpp||In function ‘int main(int, char**)’:| 
/home/david/workspace/spaceSim/main.cpp|24|warning: ‘virtual bool irr::io::IFileSystem::addZipFileArchive(const c8*, bool, bool)’ is deprecated (declared at /home/david/irrlicht-1.8.1/include/IFileSystem.h:228) [-Wdeprecated-declarations]| 
/home/david/workspace/spaceSim/objects/testObject.cpp||In constructor ‘testObject::testObject(irr::IrrlichtDevice*)’:| 
/home/david/workspace/spaceSim/objects/testObject.cpp|20|warning: comparison with string literal results in unspecified behaviour [-Waddress]| 
obj/Debug/objects/testObject.o||In function `testObject::testObject(irr::IrrlichtDevice*)':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|3|multiple definition of `testObject::testObject(irr::IrrlichtDevice*)'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|3|first defined here| 
obj/Debug/objects/testObject.o||In function `testObject::testObject(irr::IrrlichtDevice*)':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|3|multiple definition of `testObject::testObject(irr::IrrlichtDevice*)'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|3|first defined here| 
obj/Debug/objects/testObject.o||In function `testObject::~testObject()':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|27|multiple definition of `testObject::~testObject()'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|27|first defined here| 
obj/Debug/objects/testObject.o||In function `testObject::~testObject()':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|27|multiple definition of `testObject::~testObject()'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|27|first defined here| 
obj/Debug/objects/testObject.o||In function `virtual thunk to testObject::~testObject()':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|29|multiple definition of `virtual thunk to testObject::~testObject()'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|29|first defined here| 
obj/Debug/objects/testObject.o||In function `testObject::~testObject()':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|27|multiple definition of `testObject::~testObject()'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|27|first defined here| 
obj/Debug/objects/testObject.o||In function `virtual thunk to testObject::~testObject()':| 
/home/david/workspace/spaceSim/objects/testObject.cpp|29|multiple definition of `virtual thunk to testObject::~testObject()'| 
obj/Debug/main.o:/home/david/workspace/spaceSim/objects/testObject.cpp|29|first defined here| 
||=== Build finished: 14 errors, 3 warnings ===| 

我已經試過以下是解決:

  • 結合頭和cpp文件。
  • 清空所有的方法體並刪除#includes以便所有重要的是類結構。
  • 谷歌搜索(沒有任何運氣...)

感謝您的幫助!

回答

0

我從mingw32(www.mingw.org)使用gcc4.8.1編譯你的代碼(把它們放到文件中,並替換丟失的類型)。彙編似乎是確定的。我想這個問題可能是

#include <irrlicht.h> 
#include "../maths.h" 

代碼:

//#include <irrlicht.h> 
//#include "../maths.h" 

//using namespace irr; 

#ifndef testObject_H 
#define testObject_H 
#include <tuple> 
namespace scene { 
    typedef std::tuple<int,int> SAnimatedMesh; 
}; 
typedef int IrrlichtDevice; 

class testObject : public scene::SAnimatedMesh 
{ 
    public: 
     testObject(IrrlichtDevice* device); 
     virtual ~testObject(); 
    protected: 
     const char* meshInfoLocation; 
     int totAnims; 
    private: 

}; 

#endif 

//#include "testObject.h" 

testObject::testObject(IrrlichtDevice* device) : scene::SAnimatedMesh() 
{ 
    /* 
    io::IrrXMLReader* modelInformation = io::createIrrXMLReader(meshInfoLocation); 

    while(modelInformation->read()) 
    { 
     if(modelInformation->getNodeName() == "totAnims") totAnims = stringToInt(modelInformation->getAttributeValue("totAnims")); 
    } 
    */ 
} 

testObject::~testObject() { } //Incomplete, but should still compile... 

int main() {}