我在我的项目中使用Theron作为演员库,当我使用" hello world"来测试Theron时项目,我遇到了以下错误。
#include <iostream>
#include "Theron/Framework.h"
#include "Theron/Actor.h"
#include "Theron/Receiver.h"
#include "Theron/EndPoint.h"
using namespace std;
class Actor : public Theron::Actor
{
public:
explicit Actor(Theron::Framework &framework) : Theron::Actor(framework)
{
RegisterHandler(this, &Actor::Handler);
}
private:
void Handler(const int &message, const Theron::Address from)
{
Send(message, from);
}
};
int main()
{
Theron::Receiver receiver;
Theron::Framework framework;
Actor actor(framework);
framework.Send(int(0), receiver.GetAddress(), actor.GetAddress());
receiver.Wait();
return 0;
}
g++ -Wall -fexceptions -g -ITheron/Include/ -ITheron/Include/External/
-c /home/eliteyang/dev/test/main.cpp -o obj/Debug/main.o In file included from /home/eliteyang/dev/test/main.cpp:2:0: Theron/Include/Theron/Framework.h: In member function ‘bool Theron::Framework::SendInternal(Theron::Detail::MailboxContext*, Theron::Detail::IMessage*, Theron::Address)’: Theron/Include/Theron/Framework.h:999:23: error: invalid use of incomplete type ‘class Theron::EndPoint’
if (!mEndPoint->Lookup(name, address.mIndex))
^ In file included from Theron/Include/Theron/Framework.h:14:0,
from /home/eliteyang/dev/test/main.cpp:2: Theron/Include/Theron/Address.h:23:7: error: forward declaration of ‘class Theron::EndPoint’ class EndPoint;
^ In file included from /home/eliteyang/dev/test/main.cpp:2:0: Theron/Include/Theron/Framework.h:1002:29: error: invalid use of incomplete type ‘class Theron::EndPoint’
return mEndPoint->RequestSend(message, name);
^ In file included from Theron/Include/Theron/Framework.h:14:0,
from /home/eliteyang/dev/test/main.cpp:2: Theron/Include/Theron/Address.h:23:7: error: forward declaration of ‘class Theron::EndPoint’ class EndPoint;
^
我的环境是Ubuntu 15.04,代码块13.12,gcc 4.9.1。
非常感谢。
答案 0 :(得分:0)
您的include语句错误或顺序错误。
显然Theron/Framework.h
包含一些需要类EndPoint
的完整定义的代码,但没有明确包含标题EndPoint.h
,而只提供前向声明。
要解决此问题,您可以在包含EndPoint.h
之前尝试添加Framework.h
,或者使用Theron/Theron.h
包罗万象的包装替换所有Theron包含。