boostorg / asio

Boost.org asio module
http://boost.org/libs/asio
1.25k stars 418 forks source link

my bash program wont work with boost #391

Open igorgsouza opened 2 years ago

igorgsouza commented 2 years ago

I can compile and run my code using boost perfectly on the powershell, however when I try to run the executable on bash the program runs but I get no outputs, as if the program crashed

It happens when I include boost libraries, if I remove them it goes back to working, I am using CMake and Ninja to compile and run everything

igorgsouza commented 2 years ago

update: It seems that the problem are not the boost libraries itself, but rather the following function:

void print(const boost::system::error_code & /*e*/, boost::asio::steady_timer *t, Reservoir &r)
{
    while (r.time() < 10)
    {
        std::cout << "Water Level: " << r.water_level() << " Time: " << r.time() << std::endl;

        r.next_second();

        t->expires_at(t->expiry() + boost::asio::chrono::milliseconds(1000));
        t->async_wait(boost::bind(print, boost::asio::placeholders::error, t, r));
    }
}