From ece4a6f4a27f7bc45f1b1d4791c31f48ec102ce7 Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Fri, 18 Aug 2023 13:55:30 +1000 Subject: [PATCH] std::fflush() #220 Need to flush console output for AMPL IDE and SW console --- include/mp/solver-app.h | 1 + include/mp/solver-base.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/mp/solver-app.h b/include/mp/solver-app.h index 8d6359399..f7d65e5b0 100644 --- a/include/mp/solver-app.h +++ b/include/mp/solver-app.h @@ -41,6 +41,7 @@ class SolverApp : private Reader { void HandleOutput(fmt::CStringRef output) { has_output = true; std::fputs(output.c_str(), stdout); + std::fflush(stdout); // #220 } }; AppOutputHandler output_handler_; diff --git a/include/mp/solver-base.h b/include/mp/solver-base.h index 3093408c2..dc7a60b8e 100644 --- a/include/mp/solver-base.h +++ b/include/mp/solver-base.h @@ -26,6 +26,7 @@ class OutputHandler { virtual void HandleOutput(fmt::CStringRef output) { has_output = true; std::fputs(output.c_str(), stdout); + std::fflush(stdout); // #220 } }; @@ -284,6 +285,7 @@ class BasicSolver : private ErrorHandler, /// Override methods from base service classes void HandleOutput(fmt::CStringRef output) override { std::fputs(output.c_str(), stdout); + std::fflush(stdout); // #220 } /// Handle error