jassert
and DBG
only do something in case
(JUCE_DEBUG && ! JUCE_DISABLE_ASSERTIONS) || DOXYGEN
is true.
This means that code like this:
void f (std::vector<int> v)
{
for (int x : v)
jassert (x > 0);
...
}
will trigger a warning in release builds about x
being unused, unless the loop is wrapped with an #if
on the same macro condition:
void f (std::vector<int> v)
{
#if (JUCE_DEBUG && ! JUCE_DISABLE_ASSERTIONS) || DOXYGEN
for (int x : v)
jassert (x > 0);
#endif
...
}
This is both non-DRY (maybe the macro will change in the future) and cumbersome. It would be nice if there were a macro (e.g. JUCE_ASSERTIONS_ENABLED
) which would be defined, or not, according to the more complex macro condition, and could then be used in user code.
Aside: Does it make sense that DBG
is currently enabled/disabled according to the above macro condition? If I use JUCE_DISABLE_ASSERTIONS
, I might still want to see debug prints.
Thanks,
Dan