I have some rude errors... I search the web about it, and i was able to read her everywhere, but still not fix my problem ...
Here is my main :
#include <iostream>
#include "SFML/Network.hpp"
#include "decode.hpp"
#include "listOfFunction.hpp"
#include "map.hpp"
void createSocket(){
unsigned short bindPort = 12800;
unsigned short clientPort;
int ret = 0;
sf::UdpSocket socket;
sf::IpAddress clientAddr;
sf::Packet packet;
Map mainMap;
if (socket.bind(bindPort) != sf::Socket::Done){
if (sf::Socket::Error) std::cout << "An unexpected error happened : Fatal Error !" << std::endl;
if (sf::Socket::NotReady) std::cout << "The socket is not ready to send/receive data yet !" << std::endl;
}
while(1){
packet.clear();
socket.receive(packet, clientAddr, clientPort);
std::string header = readFromPacket(packet);
ret = callFunction(packet, header, clientAddr, clientPort, mainMap, socket);
}
}
int main(){
createSocket();
}
Here are the errors :
error : 'Map' was not declared in this scope error : expected ';'before 'mainMap' error : 'mainMap' was not declared in this scope error : callFunction was not declared in this scope
Map.cpp :
#include <iostream>
#include <vector>
#include "SFML/Network.hpp"
#include "map.hpp"
Map::Map(){
char number[5] = "\0";
int m_obstacle[80000] = {0};
std::string m_error = "not error";
std::vector <int> m_posPlayer(0);
std::vector <std::string> m_namePlayer(0);
std::vector <sf::IpAddress> m_addressPlayer(0);
std::string m_stringObstacle = "";
for (int i=0;i<80000;i++){
sprintf(number, "%d", m_obstacle[i]);
m_stringObstacle += std::string(number) + "+";
}
}
int Map::sendMap(sf::IpAddress address, unsigned short clientPort, sf::UdpSocket& socket){
std::string header = "rcv_map";
sf::Packet packet;
packet >> header >> m_stringObstacle;
if(socket.send(packet, address, clientPort)!=sf::UdpSocket::Done){
m_error += "Error sending the packet \n";
}
return 0;
}
int Map::error(){
if (m_error != "not_error"){
std::cout << "here is a following list of errors : " << m_error << std::endl;
}
m_error.erase(0,m_error.length());
}
Map.hpp:
#include <iostream>
#include "SFML/Network.hpp"
#ifndef DECODE_H_INCLUDED
#define DECODE_H_INCLUDED
class Map{
public:
Map();
int sendMap(sf::IpAddress address, unsigned short clientPort, sf::UdpSocket& socket);
int error();
private:
int m_obstacle;
std::vector <int> m_posPlayer;
std::vector <int> m_namePlayer;
std::vector <sf::IpAddress> m_addressPlayer;
std::string m_stringObstacle;
};
#endif // DECODE_H_INCLUDED
The problem probably exists in the headers, but I can't figure it out.
#includestatements inside your include guards. - GalikMap.hppis notmap.hpp- VolAnd