[Ns-bugs] [Bug 1170] Formulate best practices for dealing with unused debug variables
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Sun Feb 5 11:26:34 PST 2012
https://www.nsnam.org/bugzilla/show_bug.cgi?id=1170
--- Comment #26 from Mathieu Lacage <mathieu.lacage at gmail.com> 2012-02-05 14:26:34 EST ---
(In reply to comment #21)
> I just had to deal with this issue again in changeset 2778027c929c.
>
> This is a bump to try to resolve and close this issue. To review where we seem
> to be, Andrey proposed a set of new macros to cover the various issues, Mathieu
> proposed instead to handle some of these with helper functions, and Andrey
> raised a few concerns with the use of helper functions (API bloat and bigger
> symbol table).
>
> I would prefer the macros partly for the reasons Andrey cited, and partly
> because I think it will be more cumbersome for the model developers to have to
> declare and define these functions for (typically) one-time uses.
The obvious way to avoid the ifdef would be to use an explicit if statement to
wrap NS_ASSERT_MSG (the compiler will optimize away the empty statement), but,
really, NS_ASSERT_MSG should be doing this for me instead.
In general, though, I believe that the debugging macros are just plain wrong
because they do not generate the code for the if statement unconditionally.
They should and then rely on the compiler to optimize stuff away. This is what
they are here for.
i.e., a patch to replace:
#else /* NS3_ASSERT_ENABLE */
#define NS_ASSERT(cond)
with:
#else /* NS3_ASSERT_ENABLE */
#define NS_ASSERT(condition) \
do \
{ \
if (!(condition)) \
{ \
} \
} \
while (false)
is pre-approved (same for log.h)
I am actually surprised that the code we have is like this because this is a
common thing for log/assert macros to do.
--
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