错误:无效使用了不完整的类型“class Theron::EndPoint”
error: invalid use of incomplete type ‘class Theron::EndPoint’
我在项目中使用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。
非常感谢。
include语句是错误的,或者顺序错误。显然,Theron/Framework.h
包含一些代码,这些代码需要类EndPoint
的完整定义,但没有显式地包含头EndPoint.h
,而是只提供了一个前向声明。
要解决此问题,您可以尝试在包含Framework.h
之前包含EndPoint.h
,或者用Theron/Theron.h
全包包装器替换所有Theron包含。
相关文章:
- '{'标记之前的预期类名,然后在预声明时无效使用不完整的类型'class class_name'
- C2011 'CMemDC':Visual Studio 2019中的'class'类型重新定义
- C++错误:"class name"之前的预期类型说明符
- "class":非法使用此类型作为表达式 如何解决?
- 如何配置 Doxygen 以在"Class Index"中包含类的类型定义?
- 无法将'Class::operator=='从"布尔"类型(类::)(类*)转换为"布尔"类型
- 获取生成错误:错误 C2011:'ProfileSettings':'class'类型重定义
- 'class MyClass' 在尝试定义静态结构实例时不会命名类型
- 'inherit class'中类型 'template class' 引用的初始化无效
- C++模板: <class> 不命名类型
- 无效使用不完整的类型"class..."
- 无效使用不完整的类型"class"
- 错误:返回类型 'class Polar' 不完整,无效使用类型 'polar'
- 无效使用不完整的类型'class QGraphicsRectItem'
- 无效使用不完整的类型'class...'
- 错误:请求“y”中的成员“x”,该成员属于非类类型“class**”
- 我收到错误"无效使用不完整的类型'class map'
- Qt - 无效使用不完整的类型 'class QScrollBar' - 为文本编辑小部件添加水平滚动条
- 如何确定作为void *返回的指针的类型(Class)
- 错误:无效使用了不完整的类型“class Theron::EndPoint”