exporting patch: # HG changeset patch # User Andrey Mazo # Date 1305829669 -14400 # Node ID 8aca1ef4867f6a2d5df4500f923f888139735bc5 # Parent 1a9428ead0711aebe2dd41785f37ebfa7fc2e825 introduce NS_UNUSED() macro. diff --git a/examples/energy/energy-model-example.cc b/examples/energy/energy-model-example.cc --- a/examples/energy/energy-model-example.cc +++ b/examples/energy/energy-model-example.cc @@ -53,9 +53,7 @@ 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; + NS_UNUSED (iaddr); // suppress "set but not used" compiler warning in optimized builds } } } diff --git a/examples/wireless/multirate.cc b/examples/wireless/multirate.cc --- a/examples/wireless/multirate.cc +++ b/examples/wireless/multirate.cc @@ -328,17 +328,14 @@ NS_LOG_DEBUG("Set up Server Device " << (server->GetDevice(0))->GetAddress () << " with ip " << ipv4AddrServer << " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")"); + NS_UNUSED (serverPos); // suppress "set but not used" compiler warning in optimized builds NS_LOG_DEBUG("Set up Client Device " << (client->GetDevice(0))->GetAddress () << " with ip " << ipv4AddrClient << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")" << "\n"); - - //cast serverPos,clientPos,iaddrClient to void, to suppress variable set but not - //used compiler warning in optimized builds - (void) serverPos; - (void) clientPos; - (void) ipv4AddrClient; + NS_UNUSED (ipv4AddrClient); // suppress "set but not used" compiler warning in optimized builds + NS_UNUSED (clientPos); // suppress "set but not used" compiler warning in optimized builds // Equipping the source node with OnOff Application used for sending OnOffHelper onoff ("ns3::UdpSocketFactory", Address(InetSocketAddress(Ipv4Address("10.0.0.1"), port))); diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc --- a/examples/wireless/wifi-simple-interference.cc +++ b/examples/wireless/wifi-simple-interference.cc @@ -102,9 +102,7 @@ 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; + NS_UNUSED (iaddr); // suppress "set but not used" compiler warning in optimized builds } static void GenerateTraffic (Ptr socket, uint32_t pktSize, diff --git a/src/applications/model/packet-sink.cc b/src/applications/model/packet-sink.cc --- a/src/applications/model/packet-sink.cc +++ b/src/applications/model/packet-sink.cc @@ -20,6 +20,7 @@ #include "ns3/address.h" #include "ns3/address-utils.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/inet-socket-address.h" #include "ns3/node.h" #include "ns3/socket.h" @@ -169,9 +170,7 @@ 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; + NS_UNUSED (address); // suppress "set but not used" compiler warning in optimized builds } m_rxTrace (packet, from); } diff --git a/src/applications/model/v4ping.cc b/src/applications/model/v4ping.cc --- a/src/applications/model/v4ping.cc +++ b/src/applications/model/v4ping.cc @@ -17,6 +17,7 @@ #include "ns3/icmpv4.h" #include "ns3/assert.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/ipv4-address.h" #include "ns3/socket.h" #include "ns3/uinteger.h" @@ -241,9 +242,7 @@ 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; + NS_UNUSED (status); // suppress "set but not used" compiler warning in optimized builds Send (); } diff --git a/src/click/helper/click-internet-stack-helper.cc b/src/click/helper/click-internet-stack-helper.cc --- a/src/click/helper/click-internet-stack-helper.cc +++ b/src/click/helper/click-internet-stack-helper.cc @@ -24,6 +24,7 @@ #include "ns3/assert.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/object.h" #include "ns3/names.h" #include "ns3/ipv4.h" @@ -449,11 +450,12 @@ // be aggregated to the same node. // Ptr ipv4L3Protocol = ipv4->GetObject (); - bool __attribute__ ((unused)) result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", + bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream)); NS_ASSERT_MSG (result == true, "ClickInternetStackHelper::EanableAsciiIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Drop\""); + NS_UNUSED (result); } g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream; diff --git a/src/core/examples/main-callback.cc b/src/core/examples/main-callback.cc --- a/src/core/examples/main-callback.cc +++ b/src/core/examples/main-callback.cc @@ -1,6 +1,7 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "ns3/callback.h" #include "ns3/assert.h" +#include "ns3/unused.h" #include using namespace ns3; @@ -34,9 +35,7 @@ // 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; + NS_UNUSED (retOne); // suppress "set but not used" compiler warning in optimized builds // return type: int // first arg type: double @@ -49,9 +48,8 @@ // 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; + NS_UNUSED (retTwo); // suppress "set but not used" compiler warning in optimized builds + two = MakeNullCallback (); // invoking a null callback is just like // invoking a null function pointer: diff --git a/src/core/model/unused.h b/src/core/model/unused.h new file mode 100644 --- /dev/null +++ b/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 */ diff --git a/src/core/wscript b/src/core/wscript --- a/src/core/wscript +++ b/src/core/wscript @@ -235,6 +235,7 @@ 'model/vector.h', 'model/default-deleter.h', 'model/fatal-impl.h', + 'model/unused.h', ] if sys.platform == 'win32': diff --git a/src/flow-monitor/model/ipv4-flow-probe.cc b/src/flow-monitor/model/ipv4-flow-probe.cc --- a/src/flow-monitor/model/ipv4-flow-probe.cc +++ b/src/flow-monitor/model/ipv4-flow-probe.cc @@ -24,6 +24,7 @@ #include "ns3/packet.h" #include "ns3/flow-monitor.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/pointer.h" #include "ns3/config.h" #include "ns3/flow-id-tag.h" @@ -327,9 +328,8 @@ bool tagFound; tagFound = ConstCast (ipPayload)->RemovePacketTag (fTag); NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing"); - // cast tagFound to void, to suppress 'tagFound' set but not used compiler - // warning in optimized builds - (void) tagFound; + NS_UNUSED (tagFound); // suppress "set but not used" compiler warning in optimized builds + FlowId flowId = fTag.GetFlowId (); FlowPacketId packetId = fTag.GetPacketId (); uint32_t size = fTag.GetPacketSize (); diff --git a/src/internet/helper/internet-stack-helper.cc b/src/internet/helper/internet-stack-helper.cc --- a/src/internet/helper/internet-stack-helper.cc +++ b/src/internet/helper/internet-stack-helper.cc @@ -150,6 +150,7 @@ #include "ns3/assert.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/object.h" #include "ns3/names.h" #include "ns3/ipv4.h" @@ -492,9 +493,7 @@ 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; + NS_UNUSED (result); // suppress "set but not used" compiler warning in optimized builds } g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file; @@ -587,9 +586,7 @@ 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; + NS_UNUSED (result); // suppress "set but not used" compiler warning in optimized builds } g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file; @@ -742,10 +739,11 @@ // be aggregated to the same node. // Ptr ipv4L3Protocol = ipv4->GetObject (); - bool __attribute__ ((unused)) result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", + bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream)); NS_ASSERT_MSG (result == true, "InternetStackHelper::EanableAsciiIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Drop\""); + NS_UNUSED (result); } g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream; @@ -929,10 +927,11 @@ // be aggregated to the same node. // Ptr ipv6L3Protocol = ipv6->GetObject (); - bool __attribute__ ((unused)) result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop", + bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream)); NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): " "Unable to connect ipv6L3Protocol \"Drop\""); + NS_UNUSED (result); } g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream; diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -25,6 +25,7 @@ #include "ns3/node.h" #include "ns3/inet-socket-address.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/ipv4.h" #include "ns3/ipv4-interface-address.h" #include "ns3/ipv4-route.h" @@ -416,9 +417,7 @@ 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; + NS_UNUSED (found); // suppress "set but not used" compiler warning in optimized builds fromAddress = tag.GetAddress (); } return packet; diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -19,6 +19,7 @@ */ #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/node.h" #include "ns3/inet-socket-address.h" #include "ns3/ipv4-route.h" @@ -547,9 +548,7 @@ 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; + NS_UNUSED (found); // suppress "set but not used" compiler warning in optimized builds fromAddress = tag.GetAddress (); } return packet; diff --git a/src/internet/test/ipv4-raw-test.cc b/src/internet/test/ipv4-raw-test.cc --- a/src/internet/test/ipv4-raw-test.cc +++ b/src/internet/test/ipv4-raw-test.cc @@ -31,6 +31,7 @@ #include "ns3/socket.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/node.h" #include "ns3/inet-socket-address.h" #include "ns3/boolean.h" @@ -112,9 +113,7 @@ NS_ASSERT (m_receivedPacket->GetSize () == 2); m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; + NS_UNUSED (availableData); // suppress "set but not used" compiler warning in optimized builds } void Ipv4RawSocketImplTest::ReceivePkt2 (Ptr socket) @@ -125,9 +124,7 @@ NS_ASSERT (m_receivedPacket2->GetSize () == 2); m_receivedPacket2 = socket->Recv (std::numeric_limits::max(), 0); NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; + NS_UNUSED (availableData); // suppress "set but not used" compiler warning in optimized builds } void diff --git a/src/internet/test/udp-test.cc b/src/internet/test/udp-test.cc --- a/src/internet/test/udp-test.cc +++ b/src/internet/test/udp-test.cc @@ -32,6 +32,7 @@ #include "ns3/socket.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/node.h" #include "ns3/inet-socket-address.h" @@ -94,9 +95,7 @@ availableData = socket->GetRxAvailable (); m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; + NS_UNUSED (availableData); // suppress "set but not used" compiler warning in optimized builds } void @@ -155,9 +154,7 @@ availableData = socket->GetRxAvailable (); m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); NS_ASSERT (availableData == m_receivedPacket->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; + NS_UNUSED (availableData); // suppress "set but not used" compiler warning in optimized builds } void UdpSocketImplTest::ReceivePkt2 (Ptr socket) @@ -166,9 +163,7 @@ availableData = socket->GetRxAvailable (); m_receivedPacket2 = socket->Recv (std::numeric_limits::max(), 0); NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); - //cast availableData to void, to suppress 'availableData' set but not used - //compiler warning - (void) availableData; + NS_UNUSED (availableData); // suppress "set but not used" compiler warning in optimized builds } void diff --git a/src/mesh/model/dot11s/peer-management-protocol.cc b/src/mesh/model/dot11s/peer-management-protocol.cc --- a/src/mesh/model/dot11s/peer-management-protocol.cc +++ b/src/mesh/model/dot11s/peer-management-protocol.cc @@ -27,6 +27,7 @@ #include "ns3/simulator.h" #include "ns3/assert.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/random-variable.h" #include "ns3/mesh-wifi-interface-mac.h" #include "ns3/mesh-wifi-interface-mac-plugin.h" @@ -385,9 +386,7 @@ NS_ASSERT (iface != m_peerLinks.end ()); PeerManagementProtocolMacMap::const_iterator plugin = m_plugins.find (interface); NS_ASSERT (plugin != m_plugins.end ()); - // cast plugin to void, to suppress 'plugin' set but not used, compiler warning - // in optimized builds - (void) plugin; + NS_UNUSED (plugin); // suppress "set but not used" compiler warning in optimized builds std::map::const_iterator lastBeacon = m_lastBeacon.find (interface); std::map::const_iterator beaconInterval = m_beaconInterval.find (interface); if ((lastBeacon == m_lastBeacon.end ()) || (beaconInterval == m_beaconInterval.end ())) diff --git a/src/mobility/helper/ns2-mobility-helper.cc b/src/mobility/helper/ns2-mobility-helper.cc --- a/src/mobility/helper/ns2-mobility-helper.cc +++ b/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" @@ -400,8 +401,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 in optimized builds return endp == s.c_str () + s.size (); } diff --git a/src/network/helper/trace-helper.h b/src/network/helper/trace-helper.h --- a/src/network/helper/trace-helper.h +++ b/src/network/helper/trace-helper.h @@ -20,6 +20,7 @@ #define TRACE_HELPER_H #include "ns3/assert.h" +#include "ns3/unused.h" #include "ns3/net-device-container.h" #include "ns3/node-container.h" #include "ns3/simulator.h" @@ -94,9 +95,10 @@ 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 << "\""); + NS_UNUSED (result); } /** @@ -231,10 +233,11 @@ 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 << "\""); + NS_UNUSED (result); } template void @@ -244,19 +247,21 @@ 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 << "\""); + NS_UNUSED (result); } 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 << "\""); + NS_UNUSED (result); } template void @@ -266,19 +271,21 @@ 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 << "\""); + NS_UNUSED (result); } 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 << "\""); + NS_UNUSED (result); } template void @@ -288,19 +295,21 @@ 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 << "\""); + NS_UNUSED (result); } 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 << "\""); + NS_UNUSED (result); } template void @@ -310,10 +319,11 @@ 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 << "\""); + NS_UNUSED (result); } /** diff --git a/src/network/model/socket.cc b/src/network/model/socket.cc --- a/src/network/model/socket.cc +++ b/src/network/model/socket.cc @@ -21,6 +21,7 @@ */ #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/packet.h" #include "node.h" #include "socket.h" @@ -314,9 +315,7 @@ } } 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; + NS_UNUSED (found); // suppress "set but not used" compiler warning in optimized builds } m_boundnetdevice = netdevice; return; diff --git a/src/network/utils/packet-socket.cc b/src/network/utils/packet-socket.cc --- a/src/network/utils/packet-socket.cc +++ b/src/network/utils/packet-socket.cc @@ -22,6 +22,7 @@ #include "packet-socket.h" #include "packet-socket-address.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/uinteger.h" @@ -441,9 +442,7 @@ 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; + NS_UNUSED (found); // suppress "set but not used" compiler warning in optimized builds fromAddress = tag.GetAddress (); } return packet; diff --git a/src/network/utils/radiotap-header.cc b/src/network/utils/radiotap-header.cc --- a/src/network/utils/radiotap-header.cc +++ b/src/network/utils/radiotap-header.cc @@ -21,6 +21,7 @@ #include #include #include "ns3/log.h" +#include "ns3/unused.h" #include "radiotap-header.h" NS_LOG_COMPONENT_DEFINE ("RadiotapHeader"); @@ -134,8 +135,9 @@ { NS_LOG_FUNCTION (this); - uint8_t __attribute__ ((unused)) tmp = start.ReadU8 (); // major version of radiotap header + uint8_t tmp = start.ReadU8 (); // major version of radiotap header NS_ASSERT_MSG (tmp == 0x00, "RadiotapHeader::Deserialize(): Unexpected major version"); + NS_UNUSED (tmp); start.ReadU8 (); // pad field m_length = start.ReadU16 (); // entire length of radiotap data + header diff --git a/src/test/ns3wifi/wifi-interference-test-suite.cc b/src/test/ns3wifi/wifi-interference-test-suite.cc --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ b/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -21,6 +21,7 @@ #include #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/callback.h" #include "ns3/abort.h" #include "ns3/test.h" @@ -84,9 +85,7 @@ 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; + NS_UNUSED (iaddr); // suppress "set but not used" compiler warning in optimized builds } void diff --git a/src/topology-read/model/rocketfuel-topology-reader.cc b/src/topology-read/model/rocketfuel-topology-reader.cc --- a/src/topology-read/model/rocketfuel-topology-reader.cc +++ b/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 { @@ -155,11 +156,8 @@ << " 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; + NS_UNUSED (bb); // suppress "set but not used" compiler warning in optimized builds + NS_UNUSED (dns); // suppress "set but not used" compiler warning in optimized builds // Create node and link if (!uid.empty ()) @@ -209,8 +207,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]); diff --git a/src/wifi/model/wifi-information-element.cc b/src/wifi/model/wifi-information-element.cc --- a/src/wifi/model/wifi-information-element.cc +++ b/src/wifi/model/wifi-information-element.cc @@ -19,6 +19,7 @@ */ #include "ns3/wifi-information-element.h" +#include "ns3/unused.h" namespace ns3 { @@ -55,9 +56,7 @@ // 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; + NS_UNUSED (start); // suppress "set but not used" compiler warning in optimized builds return i; } diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -22,6 +22,7 @@ #include "ns3/simulator.h" #include "ns3/assert.h" #include "ns3/log.h" +#include "ns3/unused.h" #include "ns3/tag.h" #include "ns3/boolean.h" #include "ns3/double.h" @@ -368,9 +369,7 @@ 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; + NS_UNUSED (found); // suppress "set but not used" compiler warning in optimized builds return tag.GetDataMode (); } return DoGetDataMode (Lookup (address, header), fullPacketSize); @@ -386,9 +385,7 @@ 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; + NS_UNUSED (found); // suppress "set but not used" compiler warning in optimized builds return tag.GetRtsMode (); } return DoGetRtsMode (Lookup (address, header));