1
Network / Piece of network conde not compiling in g++ (it does in VS19!)
« on: November 02, 2021, 05:19:07 pm »
The send code
On windows using Visual Studio Community 2019 this compiles just fine
On linux using g++ with VSCode and sfml-vscode-boilerplate it does not comile:
Error: invalid conversion from 'size_t' {aka 'long unsigned int' to 'wchart_t*' [-fpermissive]
When turning on '-fpermissive' I believe it tries to use sf::bool, sf::string, sf::Uint8 to 64 and fails.
Am I right te presume that I am trying to do something undefined by putting a size_t into a SFML packet? And it was dumb luck it worked on windows?
Which sf:: datatype corresponds to a long unsigned int? So I could use that datatype instead to make this piece of code work.
sf::Packet actorDataPacket;
sf::Uint8 actorDataHeader = dataType::actorsBlob;
actorDataPacket << actorDataHeader;
size_t amountOfActors = listOfActors.size();
actorDataPacket << amountOfActors;
for (actors& a : listOfActors) {
int x = a.getActorCords().x;
int y = a.getActorCords().y;
int team = a.getTeam();
int type = a.getType();
actorDataPacket << x << y << team << type;
}
currentConnection.getTcpSocket()->send(actorDataPacket);
The recieve code:sf::Uint8 actorDataHeader = dataType::actorsBlob;
actorDataPacket << actorDataHeader;
size_t amountOfActors = listOfActors.size();
actorDataPacket << amountOfActors;
for (actors& a : listOfActors) {
int x = a.getActorCords().x;
int y = a.getActorCords().y;
int team = a.getTeam();
int type = a.getType();
actorDataPacket << x << y << team << type;
}
currentConnection.getTcpSocket()->send(actorDataPacket);
sf::Packet recievePacket;
sf::Socket::Status statusOfSocket = currentConnection.getTcpSocket()->receive(recievePacket);
if (statusOfSocket == sf::Socket::Done) {
sf::Uint8 recievedHeader;
recievePacket >> recievedHeader;
switch (recievedHeader) {
case dataType::actorsBlob:
size_t amountOfActors;
recievePacket >> amountOfActors;
for (int i = 0; i < amountOfActors; i++) {
int x;
int y;
int team;
int type;
recievePacket >> x;
recievePacket >> y;
recievePacket >> team;
recievePacket >> type;
listOfActors.push_back(actors(type, { x, y }, team, static_cast<int>(listOfActors.size())));
}
actorBlobRecieved = true;
break;
}
sf::Socket::Status statusOfSocket = currentConnection.getTcpSocket()->receive(recievePacket);
if (statusOfSocket == sf::Socket::Done) {
sf::Uint8 recievedHeader;
recievePacket >> recievedHeader;
switch (recievedHeader) {
case dataType::actorsBlob:
size_t amountOfActors;
recievePacket >> amountOfActors;
for (int i = 0; i < amountOfActors; i++) {
int x;
int y;
int team;
int type;
recievePacket >> x;
recievePacket >> y;
recievePacket >> team;
recievePacket >> type;
listOfActors.push_back(actors(type, { x, y }, team, static_cast<int>(listOfActors.size())));
}
actorBlobRecieved = true;
break;
}
On windows using Visual Studio Community 2019 this compiles just fine
On linux using g++ with VSCode and sfml-vscode-boilerplate it does not comile:
Error: invalid conversion from 'size_t' {aka 'long unsigned int' to 'wchart_t*' [-fpermissive]
When turning on '-fpermissive' I believe it tries to use sf::bool, sf::string, sf::Uint8 to 64 and fails.
Am I right te presume that I am trying to do something undefined by putting a size_t into a SFML packet? And it was dumb luck it worked on windows?
Which sf:: datatype corresponds to a long unsigned int? So I could use that datatype instead to make this piece of code work.