我正在尝试编译我的代码,但我不知道我做错了什么。我相信这可能是我的编译顺序,但我无法弄清楚我的错误。
我的错误代码:
g++ -w -c JokeServer.cpp
In file included from JokeServer.h:4:0,
from JokeServer.cpp:52:
AdminServer.h:9:2: error: ‘JokeServer’ does not name a type
make: *** [JokeServer.o] Error 1
谢谢你。
JokeServer.h 文件:
#ifndef JOKESERVER_H
#define JOKESERVER_H
#include "AdminServer.h"
#include "Subject.h"
#include "Observer.h"
#include "Worker.h"
class JokeServer: public Subject {
private:
AdminServer* m_admin_server;
public:
//public functions
};
#endif
AdminServer.h 文件:
#ifndef ADMINSERVER_H
#define ADMINSERVER_H
#include "JokeServer.h"
#include "AdminWorker.h"
class AdminServer {
private:
JokeServer* m_joke_server;
public:
//public functions
};
#endif
我的制作文件:
CPPFLAGS = g++ -w
all: JokeServer JokeClient AdminClient
#-------------------------------------
# JOKE SERVER
#-------------------------------------
JokeServer: JokeServer.o Worker.o JokeGenerator.o ProverbGenerator.o AdminServer.o AdminWorker.o
$(CPPFLAGS) JokeServer.o Worker.o JokeGenerator.o ProverbGenerator.o AdminServer.o AdminWorker.o -o JokeServer -lpthread
JokeServer.o: JokeServer.cpp JokeServer.h Subject.h
$(CPPFLAGS) -c JokeServer.cpp
Worker.o: Worker.cpp Worker.h Observer.h
$(CPPFLAGS) -c Worker.cpp
JokeGenerator.o: JokeGenerator.cpp JokeGenerator.h
$(CPPFLAGS) -c JokeGenerator.cpp
ProverbGenerator.o: ProverbGenerator.cpp ProverbGenerator.h
$(CPPFLAGS) -c ProverbGenerator.cpp
AdminServer.o: AdminServer.cpp AdminServer.h
$(CPPFLAGS) -c AdminServer.cpp
AdminWorker.o: AdminWorker.cpp AdminWorker.h
$(CPPFLAGS) -c AdminWorker.cpp