I am writing some macro (yes I know it's evil, but it helps me make more optimized code) that looks like this:
#define HUGGLE_DEBUG(debug, verbosity) if (Huggle::Configuration::HuggleConfiguration->Verbosity >= verbosity) \
Huggle::Syslog::HuggleLogs->DebugLog(debug, verbosity)
function DebugLog(QString, unsigned int Verbosity = 1) has optional parameter Verbosity and I would like to make it optional in macro as well, so that I can call
HUGGLE_DEBUG("some debug text");
as well as:
HUGGLE_DEBUG("more verbose text", 10);
Is it somehow possible? Note: I am using the second variable in macro, but if I didn't have it, I could just substitute it to 1
My idea is to make a variadic macro from this, which would work like this:
#define HUGGLE_DEBUG(debug, ...) Syslog::HuggleLogs->DebugLog(debug, ##__VA_ARGS__)
which would work but it would kind of not use the optimization I did in first one
inlinefunctions really turns out worse than a macro?DebugLog("some text " + fc_that_returns_text() + " bla")which itself calls lot of text processing functions. I want to avoid having to call it, unless I am really in debugging mode (that is why I want to wrap the call of function in if block of code), if the function was just inline, the parameter would have to be constructed anyway, then it just wouldn't be usedifpasses. That's the principle of inlining.HUGGLE_DEBUGwould have to be defined in a header file, but that just means that header file would need access to the declaration ofVerbosityandDebugLog. It doesn't need their definition.