I have a function that takes a parameter but that parameter is only used if a certain macro is turned on. e.g.,
void function(bool parameter_for_debug, ....some other parameters used with or without debug turned on....) {
// do some stuff with other parameters
#ifdef DEBUG
// do stuff with parameter_for_debug
#endif
}
The problem with this function is you get the unused parameter
warning when compiling with DEBUG
off.
The current solution I have is to just instead of writing a single function
, write function_without_debug
and function_with_debug
where the former doesn't contain parameter_for_debug
and the debug logic, and the latter does (with the macro flags removed). Then in the calling function, I do
#ifdef DEBUG
function_with_debug(....)
#else
function_without_debug(....)
#endif
Is there another way to approach this problem? I feel there should be. The problem with my approach is just having some overlap in the two functions.