One normal procedure to implement debugging is the use of
#ifdef DEBUG
...debugging tests...
#endif
Sometimes, a typical "checking" algorithm is needed in some parts of the code, and so one would normally like to wrap it on a function, such that the code is only called when DEBUG flag is defined. Let that function be called myDebug();
I see two natural approaches for this: either ifdef is added on each time myDebug() is called, like this:
#ifdef DEBUG
myDebug();
#endif
Or myDebug is defined as:
void myDebug()
{
#ifdef DEBUG
...code...
#endif
}
Basically, the first avoids the function calling, while the second avoid putting the code with a lot of #ifdef/#endif.
Is there any "standard" convention to choose one of the two, or another way that I don't know? Is is worth to choose the second from the "styling" point of view?
Thanks