#include <iostream>
#include "UDPSocket.h"
class Server
{
private:
UDPSocket* socket;
std::thread* networkthread;
int port;
public:
Server(int port);
void handlePacket();
};
Не могу понять в чём же дело.
UDPSocket.h
#ifndef _SOCKET_H_
#define _SOCKET_H_
#include <exception>
#include <mutex>
#ifdef __unix__
# include <errno.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/un.h>
# include <netinet/in.h>
# include <netdb.h>
# include <arpa/inet.h>
# include <unistd.h>
#define INVALID_SOCKET -1
#else
# include <winsock2.h>
# include <Ws2tcpip.h>
# include <windows.h>
# ifdef _MSC_VER
# pragma comment( lib, "Ws2_32.lib")
# endif
#endif
#define DEFAULT_PORT 19132
#define BUFFER_SIZE 1048 * 2
#include "./BinaryStream.h"
#include "Server.h"
#include <thread>
class UDPSocket
{
private:
bool isStarted;
#ifdef WIN32
SOCKET sock;
WSAData data;
#else
int sock;
#endif
public:
bool isRuning;
public:
UDPSocket();
UDPSocket(short port);
UDPSocket(std::string ip);
UDPSocket(std::string ip, short port, Server *server);
~UDPSocket();
bool bind(std::string ip, short port);
void receive();
//int send(Packet*);
void close();
Server* server;
};
#endif
Server.h включает UDPSocket.h, который включает Server.h. A Server.h не имеет защиту от многоразового включения и class Server определяется несколько раз подряд. Что бы решить проблему нужно:
Server.hinclude этих файлов)Server напишите class UDPSocket; , а перед классом UDPSocket напишите class Server;Server.h, и UDPSocket.h)Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости