--- a/examples/energy/energy-model-example.cc +++ a/examples/energy/energy-model-example.cc @@ -43,6 +43,7 @@ void ReceivePacket (Ptr socket) { +#ifdef NS3_LOG_ENABLE Ptr packet; Address from; while (packet = socket->RecvFrom (from)) @@ -53,11 +54,11 @@ NS_LOG_UNCOND ("--\nReceived one packet! Socket: "<< iaddr.GetIpv4 () << " port: " << iaddr.GetPort () << " at time = " << Simulator::Now ().GetSeconds () << "\n--"); - //cast iaddr to void, to suppress 'iaddr' set but not used compiler warning - //in optimized builds - (void) iaddr; } } +#else + while (socket->Recv ()); +#endif } /** --- a/examples/routing/manet-routing-compare.cc +++ a/examples/routing/manet-routing-compare.cc @@ -118,6 +118,27 @@ } void +PrintReceivedPacket (Ptr socket, Ptr packet) +{ +#ifdef NS3_LOG_ENABLE + SocketAddressTag tag; + bool found; + found = packet->PeekPacketTag (tag); + if (found) + { + InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ()); + NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId () + << " received one packet from " << addr.GetIpv4 ()); + } + else + { + NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId () + << " received one packet!"); + } +#endif +} + +void RoutingExperiment::ReceivePacket (Ptr socket) { Ptr packet; @@ -125,23 +146,7 @@ { bytesTotal += packet->GetSize (); packetsReceived += 1; - SocketAddressTag tag; - bool found; - found = packet->PeekPacketTag (tag); - if (found) - { - InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ()); - NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId () - << " received one packet from " << addr.GetIpv4 ()); - //cast addr to void, to suppress 'addr' set but not used - //compiler warning in optimized builds - (void) addr; - } - else - { - NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId () - << " received one packet!"); - } + PrintReceivedPacket (socket, packet); } } --- a/examples/stats/wifi-example-apps.h +++ a/examples/stats/wifi-example-apps.h @@ -25,8 +25,6 @@ * */ -// #define NS3_LOG_ENABLE // Now defined by Makefile - #include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/application.h" --- a/examples/stats/wifi-example-sim.cc +++ a/examples/stats/wifi-example-sim.cc @@ -30,8 +30,6 @@ * */ -// #define NS3_LOG_ENABLE // Now defined by Makefile - #include #include --- a/examples/wireless/multirate.cc +++ a/examples/wireless/multirate.cc @@ -89,7 +89,6 @@ private: - Vector GetPosition (Ptr node); Ptr SetupPacketReceive (Ptr node); NodeContainer GenerateNeighbors (NodeContainer c, uint32_t senderId); @@ -181,13 +180,6 @@ Simulator::Schedule (Seconds (0.1), &Experiment::CheckThroughput, this); } -Vector -Experiment::GetPosition (Ptr node) -{ - Ptr mobility = node->GetObject (); - return mobility->GetPosition (); -} - /** * * Take the grid map, divide it into 4 quadrants @@ -309,10 +301,17 @@ } } +Vector +GetPosition (Ptr node) +{ + Ptr mobility = node->GetObject (); + return mobility->GetPosition (); +} + void -Experiment::ApplicationSetup (Ptr client, Ptr server, double start, double stop) +PrintPosition (Ptr client, Ptr server) { - +#ifdef NS3_LOG_ENABLE Vector serverPos = GetPosition (server); Vector clientPos = GetPosition (client); @@ -333,12 +332,18 @@ << " with ip " << ipv4AddrClient << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")" << "\n"); +#endif +} - //cast serverPos,clientPos,iaddrClient to void, to suppress variable set but not - //used compiler warning in optimized builds - (void) serverPos; - (void) clientPos; - (void) ipv4AddrClient; +void +Experiment::ApplicationSetup (Ptr client, Ptr server, double start, double stop) +{ + Ptr ipv4Server = server->GetObject(); + + Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0); + Ipv4Address ipv4AddrServer = iaddrServer.GetLocal (); + + PrintPosition (client, server); // Equipping the source node with OnOff Application used for sending OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address ("10.0.0.1"), port))); --- a/examples/wireless/wifi-simple-interference.cc +++ a/examples/wireless/wifi-simple-interference.cc @@ -98,13 +98,12 @@ void ReceivePacket (Ptr socket) { +#ifdef NS3_LOG_ENABLE Address addr; socket->GetSockName (addr); InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr); NS_LOG_UNCOND ("Received one packet! Socket: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort ()); - //cast iaddr to void, to suppress iaddr set but not used compiler warning - //in optimized builds - (void) iaddr; +#endif } static void GenerateTraffic (Ptr socket, uint32_t pktSize, --- a/src/applications/model/packet-sink.cc +++ a/src/applications/model/packet-sink.cc @@ -151,6 +151,16 @@ } } +void PrintStats (Address& from, uint32_t packetSize, uint32_t totalRxSize) +{ +#ifdef NS3_LOG_ENABLE + InetSocketAddress address = InetSocketAddress::ConvertFrom (from); + NS_LOG_INFO ("Received " << packetSize << " bytes from " << + address.GetIpv4 () << " [" << address << "]" + << " total Rx " << totalRxSize); +#endif +} + void PacketSink::HandleRead (Ptr socket) { NS_LOG_FUNCTION (this << socket); @@ -165,13 +175,7 @@ if (InetSocketAddress::IsMatchingType (from)) { m_totalRx += packet->GetSize (); - InetSocketAddress address = InetSocketAddress::ConvertFrom (from); - NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " << - address.GetIpv4 () << " [" << address << "]" - << " total Rx " << m_totalRx); - //cast address to void , to suppress 'address' set but not used - //compiler warning in optimized builds - (void) address; + PrintStats(from, packet->GetSize (), m_totalRx); } m_rxTrace (packet, from); } --- a/src/applications/model/v4ping.cc +++ a/src/applications/model/v4ping.cc @@ -243,9 +243,6 @@ InetSocketAddress dst = InetSocketAddress (m_remote, 0); status = m_socket->Connect (dst); NS_ASSERT (status != -1); - //cast status to void, to suppress 'status' set but not used compiler warning - //in optimized builds - (void) status; Send (); } --- a/src/click/helper/click-internet-stack-helper.cc +++ a/src/click/helper/click-internet-stack-helper.cc @@ -297,7 +297,6 @@ result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink)); NS_ASSERT_MSG (result == true, "ClickInternetStackHelper::EnablePcapIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Rx\""); - (void) result; //cast to void to suppress variable set but not used compiler warning in optimized builds } g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file; @@ -450,9 +449,9 @@ // be aggregated to the same node. // Ptr ipv4L3Protocol = ipv4->GetObject (); - bool __attribute__ ((unused)) result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", - MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, - theStream)); + bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", + MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, + theStream)); NS_ASSERT_MSG (result == true, "ClickInternetStackHelper::EanableAsciiIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Drop\""); } --- a/src/click/test/ipv4-click-routing-test.cc +++ a/src/click/test/ipv4-click-routing-test.cc @@ -97,9 +97,6 @@ ret = simclick_sim_command (click->m_simNode, SIMCLICK_IFID_FROM_NAME, "eth1"); NS_TEST_EXPECT_MSG_EQ (ret, -1, "No eth1 on node"); - - // Cast ret to void to work around set-but-unused warnings from compilers - (void) ret; } class ClickIpMacAddressFromNameTest : public TestCase @@ -152,9 +149,6 @@ NS_TEST_EXPECT_MSG_EQ (strcmp (buf, "00:00:00:00:00:00"), 0, "tun0 has IP 127.0.0.1"); delete [] buf; - - // Cast ret to void to work around set-but-unused warnings from compilers - (void) ret; } class ClickTrivialTest : public TestCase @@ -197,9 +191,6 @@ NS_TEST_EXPECT_MSG_EQ (ret, 0, "eth1 does not exist, so return 0"); delete [] buf; - - // Cast ret to void to work around set-but-unused warnings from compilers - (void) ret; } class ClickIfidFromNameTestSuite : public TestSuite --- a/src/core/examples/main-callback.cc +++ a/src/core/examples/main-callback.cc @@ -34,9 +34,8 @@ // invoke cbOne function through callback instance double retOne; retOne = one (10.0, 20.0); - // cast retOne to void, to suppress variable ‘retOne’ set but - // not used compiler warning - (void) retOne; + // callback returned expected value + NS_ASSERT (retOne == 10.0); // return type: int // first arg type: double @@ -49,9 +48,9 @@ // invoke MyCb::cbTwo through callback instance int retTwo; retTwo = two (10.0); - // cast retTwo to void, to suppress variable ‘retTwo’ set but - // not used compiler warning - (void) retTwo; + // callback returned expected value + NS_ASSERT (retTwo == -5); + two = MakeNullCallback (); // invoking a null callback is just like // invoking a null function pointer: --- a/src/core/model/assert.h +++ a/src/core/model/assert.h @@ -97,8 +97,19 @@ #else /* NS3_ASSERT_ENABLE */ -#define NS_ASSERT(cond) -#define NS_ASSERT_MSG(cond,msg) +#define NS_ASSERT(condition) \ + do \ + { \ + (void)sizeof (condition); \ + } \ + while (false) + +#define NS_ASSERT_MSG(condition, message) \ + do \ + { \ + (void)sizeof (condition); \ + } \ + while (false) #endif /* NS3_ASSERT_ENABLE */ --- a/src/core/model/unused.h +++ a/src/core/model/unused.h @@ -0,0 +1,8 @@ +#ifndef UNUSED_H +#define UNUSED_H + +#ifndef NS_UNUSED +# define NS_UNUSED(x) ((void)(x)) +#endif + +#endif /* UNUSED_H */ --- a/src/core/wscript +++ a/src/core/wscript @@ -240,7 +240,8 @@ 'model/vector.h', 'model/default-deleter.h', 'model/fatal-impl.h', - 'model/system-path.h' + 'model/system-path.h', + 'model/unused.h', ] if sys.platform == 'win32': --- a/src/internet/helper/internet-stack-helper.cc +++ a/src/internet/helper/internet-stack-helper.cc @@ -492,9 +492,6 @@ result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink)); NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Rx\""); - // cast result to void, to suppress ‘result’ set but not used compiler-warning - // for optimized builds - (void) result; } g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file; @@ -587,9 +584,6 @@ result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink)); NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): " "Unable to connect ipv6L3Protocol \"Rx\""); - // cast found to void, to suppress ‘result’ set but not used compiler-warning - // for optimized builds - (void) result; } g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file; @@ -822,8 +816,8 @@ // be aggregated to the same node. // Ptr ipv4L3Protocol = ipv4->GetObject (); - bool __attribute__ ((unused)) result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", - MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream)); + bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", + MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream)); NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Drop\""); result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", @@ -1103,8 +1097,8 @@ // be aggregated to the same node. // Ptr ipv6L3Protocol = ipv6->GetObject (); - bool __attribute__ ((unused)) result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop", - MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream)); + bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop", + MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream)); NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): " "Unable to connect ipv6L3Protocol \"Drop\""); result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", --- a/src/internet/model/ipv6-l3-protocol.cc +++ a/src/internet/model/ipv6-l3-protocol.cc @@ -969,9 +969,7 @@ if (ipv6Extension) { uint8_t nextHeaderStep = 0; -#ifdef NS3_ASSERT_ENABLE uint8_t curHeader = nextHeader; -#endif nextHeaderStep = ipv6Extension->Process (p, nextHeaderPosition, ip, dst, &nextHeader, isDropped); nextHeaderPosition += nextHeaderStep; --- a/src/internet/model/nsc-tcp-socket-impl.cc +++ a/src/internet/model/nsc-tcp-socket-impl.cc @@ -449,9 +449,6 @@ bool found; found = packet->PeekPacketTag (tag); NS_ASSERT (found); - // cast found to void, to suppress 'found' set but not used - // compiler warning in optimized builds - (void) found; fromAddress = tag.GetAddress (); } return packet; --- a/src/internet/model/udp-socket-impl.cc +++ a/src/internet/model/udp-socket-impl.cc @@ -547,9 +547,6 @@ bool found; found = packet->PeekPacketTag (tag); NS_ASSERT (found); - //cast found to void, to suppress 'found' set but not used,compiler warning - //in optimized builds - (void) found; fromAddress = tag.GetAddress (); } return packet; --- a/src/internet/test/ipv4-fragmentation-test.cc +++ a/src/internet/test/ipv4-fragmentation-test.cc @@ -20,7 +20,6 @@ /** * This is the test code for ipv4-l3protocol.cc (only the fragmentation and reassembly part). */ -#define NS3_LOG_ENABLE 1 #include "ns3/test.h" #include "ns3/config.h" --- a/src/internet/test/ipv4-header-test.cc +++ a/src/internet/test/ipv4-header-test.cc @@ -99,15 +99,16 @@ void Ipv4HeaderTest::ReceivePkt (Ptr socket) { +#ifdef NS3_ASSERT_ENABLE uint32_t availableData; availableData = socket->GetRxAvailable (); m_receivedPacket = socket->Recv (2, MSG_PEEK); NS_ASSERT (m_receivedPacket->GetSize () == 2); +#endif m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); +#ifdef NS3_ASSERT_ENABLE NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; +#endif m_receivedPacket->PeekHeader (m_receivedHeader); } --- a/src/internet/test/ipv4-raw-test.cc +++ a/src/internet/test/ipv4-raw-test.cc @@ -108,28 +108,30 @@ void Ipv4RawSocketImplTest::ReceivePkt (Ptr socket) { +#ifdef NS3_ASSERT_ENABLE uint32_t availableData; availableData = socket->GetRxAvailable (); m_receivedPacket = socket->Recv (2, MSG_PEEK); NS_ASSERT (m_receivedPacket->GetSize () == 2); +#endif m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); +#ifdef NS3_ASSERT_ENABLE NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; +#endif } void Ipv4RawSocketImplTest::ReceivePkt2 (Ptr socket) { +#ifdef NS3_ASSERT_ENABLE uint32_t availableData; availableData = socket->GetRxAvailable (); m_receivedPacket2 = socket->Recv (2, MSG_PEEK); NS_ASSERT (m_receivedPacket2->GetSize () == 2); +#endif m_receivedPacket2 = socket->Recv (std::numeric_limits::max (), 0); +#ifdef NS3_ASSERT_ENABLE NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; +#endif } void --- a/src/internet/test/udp-test.cc +++ a/src/internet/test/udp-test.cc @@ -90,13 +90,14 @@ void UdpSocketLoopbackTest::ReceivePkt (Ptr socket) { +#ifdef NS3_ASSERT_ENABLE uint32_t availableData; availableData = socket->GetRxAvailable (); +#endif m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); +#ifdef NS3_ASSERT_ENABLE NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; +#endif } void @@ -151,24 +152,26 @@ void UdpSocketImplTest::ReceivePkt (Ptr socket) { +#ifdef NS3_ASSERT_ENABLE uint32_t availableData; availableData = socket->GetRxAvailable (); +#endif m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); +#ifdef NS3_ASSERT_ENABLE NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; +#endif } void UdpSocketImplTest::ReceivePkt2 (Ptr socket) { +#ifdef NS3_ASSERT_ENABLE uint32_t availableData; availableData = socket->GetRxAvailable (); +#endif m_receivedPacket2 = socket->Recv (std::numeric_limits::max (), 0); +#ifdef NS3_ASSERT_ENABLE NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; +#endif } void --- a/src/mobility/helper/ns2-mobility-helper.cc +++ a/src/mobility/helper/ns2-mobility-helper.cc @@ -42,6 +42,7 @@ #include #include #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/simulator.h" #include "ns3/node-list.h" #include "ns3/node.h" @@ -446,8 +447,7 @@ { char *endp; double v = strtod (s.c_str (), &endp); // declared with warn_unused_result - //cast v to void, to suppress v set but not used compiler warning - (void) v; + NS_UNUSED (v); // suppress "set but not used" compiler warning return endp == s.c_str () + s.size (); } --- a/src/network/helper/trace-helper.h +++ a/src/network/helper/trace-helper.h @@ -94,7 +94,7 @@ template void PcapHelper::HookDefaultSink (Ptr object, std::string tracename, Ptr file) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnectWithoutContext (tracename.c_str (), MakeBoundCallback (&DefaultSink, file)); NS_ASSERT_MSG (result == true, "PcapHelper::HookDefaultSink(): Unable to hook \"" << tracename << "\""); } @@ -231,7 +231,7 @@ template void AsciiTraceHelper::HookDefaultEnqueueSinkWithoutContext (Ptr object, std::string tracename, Ptr file) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnectWithoutContext (tracename, MakeBoundCallback (&DefaultEnqueueSinkWithoutContext, file)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultEnqueueSinkWithoutContext(): Unable to hook \"" << tracename << "\""); @@ -244,7 +244,7 @@ std::string tracename, Ptr stream) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnect (tracename, context, MakeBoundCallback (&DefaultEnqueueSinkWithContext, stream)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultEnqueueSinkWithContext(): Unable to hook \"" << tracename << "\""); @@ -253,7 +253,7 @@ template void AsciiTraceHelper::HookDefaultDropSinkWithoutContext (Ptr object, std::string tracename, Ptr file) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnectWithoutContext (tracename, MakeBoundCallback (&DefaultDropSinkWithoutContext, file)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultDropSinkWithoutContext(): Unable to hook \"" << tracename << "\""); @@ -266,7 +266,7 @@ std::string tracename, Ptr stream) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnect (tracename, context, MakeBoundCallback (&DefaultDropSinkWithContext, stream)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultDropSinkWithContext(): Unable to hook \"" << tracename << "\""); @@ -275,7 +275,7 @@ template void AsciiTraceHelper::HookDefaultDequeueSinkWithoutContext (Ptr object, std::string tracename, Ptr file) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnectWithoutContext (tracename, MakeBoundCallback (&DefaultDequeueSinkWithoutContext, file)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultDequeueSinkWithoutContext(): Unable to hook \"" << tracename << "\""); @@ -288,7 +288,7 @@ std::string tracename, Ptr stream) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnect (tracename, context, MakeBoundCallback (&DefaultDequeueSinkWithContext, stream)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultDequeueSinkWithContext(): Unable to hook \"" << tracename << "\""); @@ -297,7 +297,7 @@ template void AsciiTraceHelper::HookDefaultReceiveSinkWithoutContext (Ptr object, std::string tracename, Ptr file) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnectWithoutContext (tracename, MakeBoundCallback (&DefaultReceiveSinkWithoutContext, file)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultReceiveSinkWithoutContext(): Unable to hook \"" << tracename << "\""); @@ -310,7 +310,7 @@ std::string tracename, Ptr stream) { - bool __attribute__ ((unused)) result = + bool result = object->TraceConnect (tracename, context, MakeBoundCallback (&DefaultReceiveSinkWithContext, stream)); NS_ASSERT_MSG (result == true, "AsciiTraceHelper::HookDefaultReceiveSinkWithContext(): Unable to hook \"" << tracename << "\""); --- a/src/network/model/socket.cc +++ a/src/network/model/socket.cc @@ -314,9 +314,6 @@ } } NS_ASSERT_MSG (found, "Socket cannot be bound to a NetDevice not existing on the Node"); - //cast found to void, to suppress 'found' set but not used compiler warning - //in optimized builds - (void) found; } m_boundnetdevice = netdevice; return; --- a/src/network/utils/packet-socket.cc +++ a/src/network/utils/packet-socket.cc @@ -441,9 +441,6 @@ bool found; found = packet->PeekPacketTag (tag); NS_ASSERT (found); - //cast found to void, to suppress 'found' set but not used compiler warning - //in optimized builds - (void) found; fromAddress = tag.GetAddress (); } return packet; --- a/src/network/utils/radiotap-header.cc +++ a/src/network/utils/radiotap-header.cc @@ -134,8 +134,11 @@ { NS_LOG_FUNCTION (this); - uint8_t __attribute__ ((unused)) tmp = start.ReadU8 (); // major version of radiotap header - NS_ASSERT_MSG (tmp == 0x00, "RadiotapHeader::Deserialize(): Unexpected major version"); +#ifdef NS3_ASSERT_ENABLE + NS_ASSERT_MSG (start.ReadU8 () == 0x00, "RadiotapHeader::Deserialize(): Unexpected major version"); // major version of radiotap header +#else + start.Next (); // major version of radiotap header +#endif start.ReadU8 (); // pad field m_length = start.ReadU16 (); // entire length of radiotap data + header --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ a/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -80,13 +80,12 @@ void WifiInterferenceTestCase::ReceivePacket (Ptr socket) { +#ifdef NS3_LOG_ENABLE Address addr; socket->GetSockName (addr); InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr); NS_LOG_UNCOND ("Received one packet! Socket: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort ()); - //cast iaddr to void, to suppress 'iaddr' set but not used compiler warning - //in optimized builds - (void) iaddr; +#endif } void --- a/src/topology-read/model/rocketfuel-topology-reader.cc +++ a/src/topology-read/model/rocketfuel-topology-reader.cc @@ -25,6 +25,7 @@ #include #include "ns3/log.h" +#include "ns3/unused.h" #include "rocketfuel-topology-reader.h" namespace ns3 { @@ -76,6 +77,18 @@ int nodesNumber = 0; std::map > nodeMap; +void +PrintNodeInfo (std::string & uid, std::string & loc, bool dns, bool bb, + std::vector ::size_type neighListSize, + std::string & name, int radius) +{ + /* uid @loc [+] [bb] (num_neigh) [&ext] -> ... {-euid} ... =name[!] rn */ + NS_LOG_INFO ("Load Node[" << uid << "]: location: " << loc << " dns: " << dns + << " bb: " << bb << " neighbors: " << neighListSize + << "(" << "%d" << ") externals: \"%s\"(%d) " + << "name: " << name << " radius: " << radius); +} + NodeContainer RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[]) { @@ -150,16 +163,7 @@ return nodes; } - /* uid @loc [+] [bb] (num_neigh) [&ext] -> ... {-euid} ... =name[!] rn */ - NS_LOG_INFO ("Load Node[" << uid << "]: location: " << loc << " dns: " << dns - << " bb: " << bb << " neighbors: " << neigh_list.size () - << "(" << "%d" << ") externals: \"%s\"(%d) " - << "name: " << name << " radius: " << radius); - - //cast bb and dns to void, to suppress variable set but not used compiler warning - //in optimized builds - (void) bb; - (void) dns; + PrintNodeInfo (uid, loc, dns, bb, neigh_list.size (), name, radius); // Create node and link if (!uid.empty ()) @@ -209,8 +213,7 @@ sname = argv[0]; tname = argv[1]; double v = strtod (argv[2], &endptr); // weight - // cast v to void , to suppress 'v' set but not used compiler warning - (void) v; + NS_UNUSED (v); // suppress "set but not used" compiler warning in optimized builds if (*endptr != '\0') { NS_LOG_WARN ("invalid weight: " << argv[2]); --- a/src/wifi/model/wifi-information-element.cc +++ a/src/wifi/model/wifi-information-element.cc @@ -55,9 +55,6 @@ // This IE was not optional, so confirm that we did actually // deserialise something. NS_ASSERT (i.GetDistanceFrom (start) != 0); - // cast start to void, to suppress ‘start’ set but not used - // compiler warning in optimized builds - (void) start; return i; } --- a/src/wifi/model/wifi-remote-station-manager.cc +++ a/src/wifi/model/wifi-remote-station-manager.cc @@ -368,9 +368,6 @@ bool found; found = ConstCast (packet)->PeekPacketTag (tag); NS_ASSERT (found); - // cast found to void, to suppress 'found' set but not used - // compiler warning - (void) found; return tag.GetDataMode (); } return DoGetDataMode (Lookup (address, header), fullPacketSize); @@ -386,9 +383,6 @@ bool found; found = ConstCast (packet)->PeekPacketTag (tag); NS_ASSERT (found); - // cast found to void, to suppress 'found' set but not used - // compiler warning - (void) found; return tag.GetRtsMode (); } return DoGetRtsMode (Lookup (address, header));