lundi 1 mai 2017

Segmentation fault (core dumped)

I have a listener.cpp and a sender.cpp compiled together into a main.

In sender.h which I've imported to `listener.cpp' I get

Segmentation fault (core dumped)

When trying to increment an int in listener.cpp by doing

sender->packet_number++;

Where packet_number is said integer.

Code to replicate:

sender.h

class BoostUDPSender {
public:
    BoostUDPSender();
    BoostUDPSender(boost::asio::io_service& io_service, boost::asio::ip::udp::endpoint remote_host_endpoint);
    boost::asio::ip::udp::socket socket;
    int packet_number;

sender.cpp - only reference to packet_number is:

std::ostringstream oss;
        oss << packet_number << "," << "1";
        std::string outbounddata = oss.str();

listener.cpp

boostUDPSender->packet_number++;

Aucun commentaire:

Enregistrer un commentaire