c++: error: cannot convert ‘ns3::TracedValue<ns3::SequenceNumber<unsigned int, int> >’ to ‘uint32_t {aka unsigned int}
c++: error: cannot convert ‘ns3::TracedValue<ns3::SequenceNumber<unsigned int, int> >’ to ‘uint32_t {aka unsigned int}
我正在尝试将 TracedValue<uint32_t> m_bytesInFlight
转换为 uint32_t 但出现以下错误
error: cannot convert ‘ns3::TracedValue<ns3::SequenceNumber<unsigned int, int> >’ to ‘uint32_t {aka unsigned int}
函数原型和变量声明是
uint32_t UnAckDCount (void) const;
TracedValue<uint32_t> m_bytesInFlight {0}; //!< Bytes in flight
这里我调用函数
uint32_t
TcpSocketBase::UnAckDCount () const
{
return m_tcb->m_highTxMark - (uint32_t) m_tcb->m_bytesInFlight;
}
请建议一些方法,以便我可以执行 return 语句以获得结果。提前致谢
将 m_tcb->m_highTxMark
更改为 m_tcb->m_highTxMark.Get().GetValue()
应该有效。
看到编译错误,很容易看出变量m_highTxMark
的类型是ns3::TracedValue<ns3::SequenceNumber<unsigned int, int> >
。我查看了 ns3::TracedValue
和 ns3::SequenceNumber
的文档,它们分别具有 getter 函数 Get() 和 GetValue()。
参见:
https://www.nsnam.org/doxygen/classns3_1_1_traced_value.html
https://www.nsnam.org/doxygen/classns3_1_1_sequence_number.html
我正在尝试将 TracedValue<uint32_t> m_bytesInFlight
转换为 uint32_t 但出现以下错误
error: cannot convert ‘ns3::TracedValue<ns3::SequenceNumber<unsigned int, int> >’ to ‘uint32_t {aka unsigned int}
函数原型和变量声明是
uint32_t UnAckDCount (void) const;
TracedValue<uint32_t> m_bytesInFlight {0}; //!< Bytes in flight
这里我调用函数
uint32_t
TcpSocketBase::UnAckDCount () const
{
return m_tcb->m_highTxMark - (uint32_t) m_tcb->m_bytesInFlight;
}
请建议一些方法,以便我可以执行 return 语句以获得结果。提前致谢
将 m_tcb->m_highTxMark
更改为 m_tcb->m_highTxMark.Get().GetValue()
应该有效。
看到编译错误,很容易看出变量m_highTxMark
的类型是ns3::TracedValue<ns3::SequenceNumber<unsigned int, int> >
。我查看了 ns3::TracedValue
和 ns3::SequenceNumber
的文档,它们分别具有 getter 函数 Get() 和 GetValue()。
参见:
https://www.nsnam.org/doxygen/classns3_1_1_traced_value.html https://www.nsnam.org/doxygen/classns3_1_1_sequence_number.html