RedhawkSDR / libRfSimulators

Library used to simulate an RF Digitizer
GNU General Public License v3.0
7 stars 5 forks source link

error: no matching conversion for functional-style cast from 'double' to 'boost::posix_time::milliseconds' #1

Open Martinfx opened 1 year ago

Martinfx commented 1 year ago

Hi, I have a problem with this issue. FreeBSD 13.1-RELEASE-p1 FreeBSD 13.1-RELEASE-p1 GENERIC amd64

FmRdsSimulatorImpl.cpp:22:17: warning: using directive refers to implicitly-defined namespace 'std'
using namespace std;
                ^
In file included from FmRdsSimulatorImpl.cpp:25:
/usr/local/include/boost/bind.hpp:36:1: warning: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior. [-W#pragma-messages]
BOOST_PRAGMA_MESSAGE(
^
/usr/local/include/boost/config/pragma_message.hpp:24:34: note: expanded from macro 'BOOST_PRAGMA_MESSAGE'
# define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x)))
                                 ^
<scratch space>:190:2: note: expanded from here
 message("The practice of declaring the Bind placeholders (_1, _2, ...) " "in the global namespace is deprecated. Please use " "<boost/bind/bind.hpp> + using namespace boost::placeholders, " "or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.")
 ^
FmRdsSimulatorImpl.cpp:248:26: error: no matching conversion for functional-style cast from 'double' to 'boost::posix_time::milliseconds' (aka 'subsecond_duration<boost::posix_time::time_duration, 1000>')
        alarm->expires_from_now(boost::posix_time::milliseconds(CALLBACK_INTERVAL));
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/date_time/time_duration.hpp:281:30: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'double' to 'const boost::date_time::subsecond_duration<boost::posix_time::time_duration, 1000>' for 1st argument
  class BOOST_SYMBOL_VISIBLE subsecond_duration : public base_duration
                             ^
/usr/local/include/boost/date_time/time_duration.hpp:297:81: note: candidate template ignored: disabled by 'enable_if' [with T = double]
                                                      typename boost::enable_if<boost::is_integral<T>,
                                                                                ^
FmRdsSimulatorImpl.cpp:283:36: error: no matching conversion for functional-style cast from 'double' to 'boost::posix_time::milliseconds' (aka 'subsecond_duration<boost::posix_time::time_duration, 1000>')
        if ( (alarm->expires_from_now() + boost::posix_time::milliseconds(CALLBACK_INTERVAL)).is_negative() ) {
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/date_time/time_duration.hpp:281:30: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'double' to 'const boost::date_time::subsecond_duration<boost::posix_time::time_duration, 1000>' for 1st argument
  class BOOST_SYMBOL_VISIBLE subsecond_duration : public base_duration
                             ^
/usr/local/include/boost/date_time/time_duration.hpp:297:81: note: candidate template ignored: disabled by 'enable_if' [with T = double]
                                                      typename boost::enable_if<boost::is_integral<T>,
                                                                                ^
FmRdsSimulatorImpl.cpp:290:42: error: no matching conversion for functional-style cast from 'double' to 'boost::posix_time::milliseconds' (aka 'subsecond_duration<boost::posix_time::time_duration, 1000>')
        alarm->expires_at(alarm->expires_at() + boost::posix_time::milliseconds(CALLBACK_INTERVAL));
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/date_time/time_duration.hpp:281:30: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'double' to 'const boost::date_time::subsecond_duration<boost::posix_time::time_duration, 1000>' for 1st argument
  class BOOST_SYMBOL_VISIBLE subsecond_duration : public base_duration
                             ^
/usr/local/include/boost/date_time/time_duration.hpp:297:81: note: candidate template ignored: disabled by 'enable_if' [with T = double]
                                                      typename boost::enable_if<boost::is_integral<T>,
                                                                                ^
In file included from FmRdsSimulatorImpl.cpp:24:
In file included from ../include/FmRdsSimulatorImpl.h:31:
In file included from ../include/RfSimulator.h:29:
In file included from ../include/CallbackInterface.h:29:
/usr/include/c++/v1/valarray:4334:52: error: 'value_type' is a private member of 'std::allocator<void>'
    __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
                                                   ^
/usr/local/include/boost/asio/execution/any_executor.hpp:887:30: note: while substituting deduced template arguments into function template 'operator==' [with _Expr1 = boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>, _Expr2 = boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>]
    return *ex1.target<Ex>() == *ex2.target<Ex>();
                             ^
Martinfx commented 1 year ago

here is patch:


--- src/FmRdsSimulatorImpl.cpp.orig     2021-04-05 15:00:09 UTC
+++ src/FmRdsSimulatorImpl.cpp
@@ -245,7 +245,7 @@ void FmRdsSimulatorImpl::stop() {

 void FmRdsSimulatorImpl::_start() {
        TRACE("Entered Method");
-       alarm->expires_from_now(boost::posix_time::milliseconds(CALLBACK_INTERVAL));
+       alarm->expires_from_now(boost::posix_time::milliseconds(static_cast<int64_t>(CALLBACK_INTERVAL)));
        io.run();
        TRACE("Leaving Method");
 }
@@ -280,14 +280,14 @@ void FmRdsSimulatorImpl::dataGrab(const boost::system:
        TRACE("Entered Method");

        TRACE("Checking Timer isn't overdue by a full cycle");
-       if ( (alarm->expires_from_now() + boost::posix_time::milliseconds(CALLBACK_INTERVAL)).is_negative() ) {
+       if ( (alarm->expires_from_now() + boost::posix_time::milliseconds(static_cast<int64_t>(CALLBACK_INTERVAL))).is_negative() ) {
                //TODO: Should this be a warning or an error?  Or an exception?
                WARN("Data delivery is lagging from real-time.  Consider reducing the number of input files.");
        }

        TRACE("Reseting alarm");
        // Reset timer
-       alarm->expires_at(alarm->expires_at() + boost::posix_time::milliseconds(CALLBACK_INTERVAL));
+       alarm->expires_at(alarm->expires_at() + boost::posix_time::milliseconds(static_cast<int64_t>(CALLBACK_INTERVAL)));