From 03885a6853e67c6274a78003223e740fc01274f3 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 12 May 2023 17:59:47 +0200 Subject: [PATCH] Fix undefined `std::round` compilation error (#1989) In some implementations round is at the global scope as `::round` and some other implementations make it available as `std::round`. The changes use the `float roundf(float)` flavor to make sure that we don't use `double round(double)` if this function isn't overloaded with the float type. --- src/IRac.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/IRac.cpp b/src/IRac.cpp index 8826bc1ae..4075e2c5a 100644 --- a/src/IRac.cpp +++ b/src/IRac.cpp @@ -13,6 +13,11 @@ #include #endif #include +#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_MATH_TR1) + using std::roundf; +#else + using ::roundf; +#endif #include "IRsend.h" #include "IRremoteESP8266.h" #include "IRtext.h" @@ -489,9 +494,9 @@ void IRac::argo(IRArgoAC *ac, ac->begin(); ac->setPower(on); ac->setMode(ac->convertMode(mode)); - ac->setTemp(static_cast(std::round(degrees))); + ac->setTemp(static_cast(roundf(degrees))); if (sensorTemp != kNoTempValue) { - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); } ac->setiFeel(iFeel); ac->setFan(ac->convertFan(fan)); @@ -537,7 +542,7 @@ void IRac::argoWrem3_ACCommand(IRArgoAC_WREM3 *ac, const bool on, ac->setMode(ac->convertMode(mode)); ac->setTemp(degrees); if (sensorTemp != kNoTempValue) { - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); } ac->setiFeel(iFeel); ac->setFan(ac->convertFan(fan)); @@ -563,7 +568,7 @@ void IRac::argoWrem3_ACCommand(IRArgoAC_WREM3 *ac, const bool on, void IRac::argoWrem3_iFeelReport(IRArgoAC_WREM3 *ac, const float sensorTemp) { ac->begin(); ac->setMessageType(argoIrMessageType_t::IFEEL_TEMP_REPORT); - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); ac->send(); } @@ -738,7 +743,7 @@ void IRac::coolix(IRCoolixAC *ac, // No Econo setting available. // No Quiet setting available. if (sensorTemp != kNoTempValue) { - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); } else { ac->clearSensorTemp(); } @@ -1128,7 +1133,7 @@ void IRac::ecoclim(IREcoclimAc *ac, ac->setTemp(degrees); ac->setFan(ac->convertFan(fan)); if (sensorTemp != kNoTempValue) { - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); } else { ac->setSensorTemp(degrees); //< Set to the desired temp // until we can disable. @@ -1174,7 +1179,7 @@ void IRac::electra(IRElectraAc *ac, ac->setMode(ac->convertMode(mode)); ac->setTemp(degrees); if (sensorTemp != kNoTempValue) { - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); } ac->setFan(ac->convertFan(fan)); ac->setSwingV(swingv != stdAc::swingv_t::kOff); @@ -2288,7 +2293,7 @@ void IRac::sanyo(IRSanyoAc *ac, ac->setMode(ac->convertMode(mode)); ac->setTemp(degrees); if (sensorTemp != kNoTempValue) { - ac->setSensorTemp(static_cast(std::round(sensorTemp))); + ac->setSensorTemp(static_cast(roundf(sensorTemp))); } else { ac->setSensorTemp(degrees); // Set the sensor temp to the desired // (normal) temp.