In my code I use a macro that should generate a log entry or it should not according to some compilation flag:
#ifdef SOMETHING
#define LOG(a) printf ("%s", a)
#else
#define LOG(a) while (0) {}
#endif
This code is working fine, but when I look in the Internet, I only see people using
#define LOG(a) do {} while (0)
instead of
#define LOG(a) while (0) {}
Are these two approaches equivalent? Should I prefer one over the other?