samedi 29 avril 2017

Error 2 files include each other

i have this problems while trying to include 2 files each other:

./include/../include/../src/Socket/../LinuxClass/ThreadingPool.hpp:38:5: error: ‘Client’ does not name a type Client client;

I already find a solution about declaring the first class in the second files but the error is still there here is the 2 .h

#ifndef THREADINGPOOL_HPP_

#define THREADINGPOOL_HPP_

#include <functional>
#include <algorithm>
#include <queue>
#include "../Socket/Client.hpp"
#include "../Intefaces/IThread.hpp"
#include "Mutex.hpp"
#include "Thread.hpp"
#include "Condvar.hpp"
#include "Process.hpp"

class ThreadingPool {

  public:
    ThreadingPool(unsigned int num_thr);
    ~ThreadingPool();
    void Add_fct(std::function<void()> job);
  private:
    enum States {LIVE, DIE};
    std::vector<std::thread> thrdVec;
    std::vector<States> states;
    std::queue<std::function<void()>> jobs;
    Mutex mtex;
    Condvar cond;
    Process pros;
    Client client;
};

#endif  /* !THREADINGPOOL_HPP_ */

And the second one

#ifndef CLIENT_HPP_
# define CLIENT_HPP_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <functional>

#include <unistd.h>

#include <fcntl.h>

#include <sys/socket.h>
#include <arpa/inet.h>

#define PORT 1043
#define METASIZE 1024

#include "check_cmd.hpp"

class ThreadingPool;

class Client {
public:
    Client();
    ~Client();

void ifMessage(ThreadingPool * thrdPool);

private:
    int csock;
    struct sockaddr_in csin;

};

#endif

Aucun commentaire:

Enregistrer un commentaire