diff --git a/src/core/model/log-macros-disabled.h b/src/core/model/log-macros-disabled.h index 368fe152a..4b4d51541 100644 --- a/src/core/model/log-macros-disabled.h +++ b/src/core/model/log-macros-disabled.h @@ -29,16 +29,47 @@ #define NS3_LOG_MACROS_DISABLED_H #ifndef NS3_LOG_ENABLE +/* + Implementation Note: + + std::clog << msg + This expression is required for forms like NS_LOG_LOGIC (... << std::endl ...) + + + ns3::ParameterLogger (std::clog) << msg + This expression is required for NS_LOG_FUNCTION (... << vector ...) + + IMO ParameterLogger should work for both cases, but it fails + with the error: + + note: in expansion of macro NS_LOG_LOGIC (std::endl... + error: no match for operator<< (operand types are ns3::ParameterLogger + and ) + + note: candidate: template ns3::ParameterLogger& + ns3::ParameterLogger::operator<<(T) + note: template argument deduction/substitution failed + note: couldn't deduce template parameter T + + Note that std::endl is templated manipulator function, which needs the + target stream to resolve it's own template parameters. The compiler + should deduce this from the ParameterLogger::operator<< () + implementation, but evidently fails to do so. + +*/ + /** * \ingroup logging * Empty logging macro implementation, used when logging is disabled. */ #define NS_LOG_NOOP_INTERNAL(msg) \ - while (false) \ + do \ + if (false) \ { \ std::clog << msg; \ - } + } \ + while (false) #define NS_LOG(level, msg) \ NS_LOG_NOOP_INTERNAL (msg) @@ -50,10 +81,12 @@ * Empty logging macro implementation, used when logging is disabled. */ #define NS_LOG_NOOP_FUNC_INTERNAL(msg) \ - while (false) \ + do \ + if (false) \ { \ ns3::ParameterLogger (std::clog) << msg; \ - } + } \ + while (false) #define NS_LOG_FUNCTION(parameters) \ NS_LOG_NOOP_FUNC_INTERNAL (parameters) diff --git a/src/lte/model/lte-rlc-am.cc b/src/lte/model/lte-rlc-am.cc index 3e2c81172..c37f8abd0 100644 --- a/src/lte/model/lte-rlc-am.cc +++ b/src/lte/model/lte-rlc-am.cc @@ -1194,18 +1194,10 @@ LteRlcAm::ReassembleAndDeliver (Ptr packet) std::list < Ptr >::iterator it; // Current reassembling state - if (m_reassemblingState == WAITING_S0_FULL) - { - NS_LOG_LOGIC ("Reassembling State = 'WAITING_S0_FULL'"); - } - else if (m_reassemblingState == WAITING_SI_SF) - { - NS_LOG_LOGIC ("Reassembling State = 'WAITING_SI_SF'"); - } - else - { - NS_LOG_LOGIC ("Reassembling State = Unknown state"); - } + if (m_reassemblingState == WAITING_S0_FULL) NS_LOG_LOGIC ("Reassembling State = 'WAITING_S0_FULL'"); + else if (m_reassemblingState == WAITING_SI_SF) NS_LOG_LOGIC ("Reassembling State = 'WAITING_SI_SF'"); + else NS_LOG_LOGIC ("Reassembling State = Unknown state"); + // Received framing Info NS_LOG_LOGIC ("Framing Info = " << (uint16_t)framingInfo); diff --git a/src/lte/model/lte-rlc-um.cc b/src/lte/model/lte-rlc-um.cc index 8abd77ce9..1db0bc93e 100644 --- a/src/lte/model/lte-rlc-um.cc +++ b/src/lte/model/lte-rlc-um.cc @@ -648,18 +648,9 @@ LteRlcUm::ReassembleAndDeliver (Ptr packet) std::list < Ptr >::iterator it; // Current reassembling state - if (m_reassemblingState == WAITING_S0_FULL) - { - NS_LOG_LOGIC ("Reassembling State = 'WAITING_S0_FULL'"); - } - else if (m_reassemblingState == WAITING_SI_SF) - { - NS_LOG_LOGIC ("Reassembling State = 'WAITING_SI_SF'"); - } - else - { - NS_LOG_LOGIC ("Reassembling State = Unknown state"); - } + if (m_reassemblingState == WAITING_S0_FULL) NS_LOG_LOGIC ("Reassembling State = 'WAITING_S0_FULL'"); + else if (m_reassemblingState == WAITING_SI_SF) NS_LOG_LOGIC ("Reassembling State = 'WAITING_SI_SF'"); + else NS_LOG_LOGIC ("Reassembling State = Unknown state"); // Received framing Info NS_LOG_LOGIC ("Framing Info = " << (uint16_t)framingInfo);