[Ns-bugs] [Bug 1170] Formulate best practices for dealing with unused debug variables
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Thu Jul 7 01:50:13 PDT 2011
https://www.nsnam.org/bugzilla/show_bug.cgi?id=1170
Mathieu Lacage <mathieu.lacage at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mathieu.lacage at gmail.com
--- Comment #13 from Mathieu Lacage <mathieu.lacage at gmail.com> 2011-07-07 04:50:13 EDT ---
(In reply to comment #12)
> (In reply to comment #11)
> > (In reply to comment #10)
> > > Here is a revised proposal; will ask on ns-developers if this is an acceptable
> > > solution.
> >
> > +1
>
>
> Seems like lazy consensus to proceed; Andrey volunteered to create the patch.
I know I am coming late to the discussion but I really don't see much point in
introducing the new macros and hiding #ifdef. If you really need #ifdef, use it
but use it sparingly. In the cases where you might need to use it a lot, you
just need to restructure your code by creating helper functions.
For example:
> > #ifdef NS3_LOG_ENABLE
> > InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
> > NS_LOG_UNCOND ("Received one packet! Socket: " << iaddr.GetIpv4 () << "
> > port: " << iaddr.GetPort ());
> > #endif
Ipv4Address ToIpv4 (const Address &addr)
{
InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
return iaddr.GetIpv4 ();
}
Same for ToPort
and finally:
NS_LOG_DEBUG ("Received one packet! Socket: " << ToIpv4(addr) << " port: " <<
ToPort (addr));
The above is simple, low tech, fairly easy to read and is simply what everyone
else has been doing forever in every other project. Why can't we do the same ?
--
Configure bugmail: https://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Ns-bugs
mailing list