Empty function macros

You’re absolutely correct, the empty macro doesn’t generate any code.

I’ve seen two places where this is useful. The first is to eliminate warnings when a function parameter isn’t used:

#define UNUSED(x)

int foo(int UNUSED(value))
{
    return 42;
}

The second is when you use conditionals to determine if there should be code or not.

#ifdef LOGGING_ENABLED
#define LOG(x) log_message(x)
#else
#define LOG(x)
#endif

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)