Bug 1170: Formulate best practices for dealing with unused debug variables.

Fixed clang-3.4 unused function warnings in optimized builds like the following:
"""
../examples/energy/energy-model-example.cc:39:1: error: unused function
'PrintReceivedPacket' [-Werror,-Wunused-function]
PrintReceivedPacket (Address& from)
^
1 error generated.
"""

Implemented "if (false)" trick inside NS_LOG* macros for optimized builds.

"sizeof()" trick might be a little better but it produces the following
warning with clang-3.4:
"""
../examples/energy/energy-model-example.cc:39:1: error: function
'PrintReceivedPacket' is not needed and will not be emitted
[-Werror,-Wunneeded-internal-declaration]
PrintReceivedPacket (Address& from)
^
1 error generated.
"""


Macros from log.h, that depend on NS3_LOG_ENABLE, were moved to log-macros-enabled.h and log-macros-disabled.h to make log.h smaller.
This commit is contained in:
Andrey Mazo
2014-03-23 19:08:54 +04:00
parent de004b4c7d
commit 210aefc777
6 changed files with 280 additions and 214 deletions

View File

@@ -108,14 +108,12 @@ static std::string Name (std::string str, uint32_t totalStreamSize,
return oss.str ();
}
#ifdef NS3_LOG_ENABLE
static std::string GetString (Ptr<Packet> p)
static inline std::string GetString (Ptr<Packet> p)
{
std::ostringstream oss;
p->CopyData (&oss, p->GetSize ());
return oss.str ();
}
#endif /* NS3_LOG_ENABLE */
TcpTestCase::TcpTestCase (uint32_t totalStreamSize,
uint32_t sourceWriteSize,