Bugzilla – Bug 2517
compile error on mac due to undefined uint16_t
Last modified: 2018-05-19 22:18:30 UTC
Assume it's just missing an include to <stdint.h> or I guess <cstdint> [1312/1858] Compiling src/aodv/model/aodv-routing-protocol.cc [1313/1858] Compiling src/olsr/model/olsr-header.cc [1314/1858] Compiling src/internet-apps/model/radvd-prefix.cc [1315/1858] Compiling src/stats/model/data-collection-object.cc [1316/1858] Compiling src/bridge/model/bridge-net-device.cc [1317/1858] Compiling src/internet/model/ipv4-interface-address.cc [1318/1858] Compiling build/src/network/bindings/ns3module.cc [1319/1858] Compiling src/wifi/model/interference-helper.cc [1320/1858] Compiling src/aodv/model/aodv-dpd.cc [1321/1858] Compiling src/energy/model/energy-harvester.cc ../src/aodv/model/aodv-routing-protocol.cc:1056:24: error: unexpected type name 'uint16_t': expected expression retry = std::pow<uint16_t> (2, rt.GetRreqCnt () - 1) * m_netTraversalTime; ^ ../src/aodv/model/aodv-routing-protocol.cc:1056:35: error: expression result unused [-Werror,-Wunused-value] retry = std::pow<uint16_t> (2, rt.GetRreqCnt () - 1) * m_netTraversalTime; ^ 2 errors generated.
I encountered the same issue when starting from a new repo on my MacOS machine
I believe it is an issue related to C++11
Created attachment 2709 [details] patch to fix
patch attached that avoids std::pow usage
Thanks. Why do you initializeTime retry to m_netTraversalTime, this will get anyway overwritten?
(In reply to sebastien.deronne from comment #5) > Thanks. Why do you initializeTime retry to m_netTraversalTime, this will get > anyway overwritten? for the case when (rt.GetRreqCnt () <= 1)
Tbh, GetRreqCnt returns a uint8_t. As a consequence if it's <= 1 it's either 0 or 1. If it's zero we should raise an assert. If it's 1, then "(1 << backoffFactor)" is 1 and the result what we would expect. Summarizing, using an if is a matter of personal taste in the code, I'm totally neutral. (In reply to Tom Henderson from comment #6) > (In reply to sebastien.deronne from comment #5) > > Thanks. Why do you initializeTime retry to m_netTraversalTime, this will get > > anyway overwritten? > > for the case when (rt.GetRreqCnt () <= 1)
Created attachment 2710 [details] revised patch to fix revised patch to address the comments received
I will push shortly if no other comments.
pushed in 13554:cf0f581e4155