I have a logging macro that is made of multiple functions and i looks like this:
#define MY_LOG(s) { myMutex.lock(); std::cout << __PRETTY_FUNCTION__ << " (" << __LINE << ")" << s << std::endl; myMutex.unlock(); }
I want to be able to call the macro so it looks similar to calling a normal function. I want to have it beeing terminated by a semicolon.
It does work in most cases. Here is an example:
if (1 == 1)
MY_LOG("ok " << 1);
It works fine. No problem. But it does not work in this case:
if (1 == 1)
MY_LOG("1 == 1");
else
c++;
I get an error that there is an else without previous if. Is it possible to fix this?