我想獲得一個項目來編譯,我遇到了不完整類型的問題。下面是使輸出:類型是不完整的,因爲包括警衛
In file included from ../common/ClientCommunication.h:13,
from EchoService_stub.h:9,
from EchoService_stub.cpp:1:
../common/Naming_stub.h:16: error: field ‘clientCommunication’ has incomplete type
In file included from EchoService_stub.h:9,
from EchoService_stub.cpp:1:
../common/ClientCommunication.h:20: error: field ‘serverEndpoint’ has incomplete type
make: *** [EchoService_stub.o] Error 1
這裏有問題我的頭文件:
在Naming_stub.h:
ifndef NAMING_STUB_H__
#define NAMING_STUB_H__
#include <string>
#include <string.h>
#include "Naming.h"
class ClientCommunication;
class Naming_stub : public Naming {
private:
ClientCommunication clientCommunication;
protected:
// Protected Methods Here.
public:
// Public Methods Here.
};
#endif
在Naming.h
#ifndef NAMING_H__
#define NAMING_H__
#include "Remote.h"
#include "../util/RemoteException.h"
class Naming {
private:
protected:
public:
virtual Remote* lookup(std::string lookupURL) throw (RemoteException);
virtual void bind() throw (RemoteException);
~Naming();
};
#endif // NAMING_H__
最後,有ClientCommunication.h文件:
#ifndef CLIENT_COMMUNICATION_H__
#define CLIENT_COMMUNICATION_H__
#include <iostream>
#include <cstdlib>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "../util/RemoteTypes.h"
#include "Naming_stub.h"
struct Endpoint;
class ClientCommunication {
private:
int socket_fd;
struct Endpoint serverEndpoint;
protected:
public:
ClientCommunication(const struct Endpoint& serverEndpoint_in);
struct Buffer send(struct Buffer& callBuffer);
~ClientCommunication();
};
#endif // CLIENT_COMMUNICATION_H__
對不起,這是如此之久,但還有一個頭文件。 Endpoint結構聲明在RemoteTypes.h中,如下所示:
#ifndef REMOTE_EXCEPTION_H__
#define REMOTE_EXCEPTION_H__
#include <netinet/in.h>
struct Endpoint {
int port;
char* service_id;
char* server_ip;
struct sockaddr_in host_name;
};
struct Buffer {
char* contents;
int size;
};
#endif
謝謝!
不要在您的標識符中使用雙下劃線,[它們是保留](http://stackoverflow.com/questions/228783/what-are -the-規則約-使用-AN-下劃線在-AC-標識符)。 – GManNickG