Home > database >  What does this C define macro do?
What does this C define macro do?

Time:01-25

What does this define macro do? I assumed that this will print the given string to the standard output, but it just not printed out nothing. Am I wrong about this?

#define SCOPE_LOGGER(...)
...
void someClass::someFunction() { SCOPE_LOGGER("someClass::someFunction()"); ... }

CodePudding user response:

As per KamilCuk's answer, that macro expands to nothing.

However, most likely it does expand to something through some other preprocessing conditional path, i.e. imho that line appears in the code like this:

#ifdef DEBUG
#define SCOPE_LOGGER(...) something real that does the logging
#else
#define SCOPE_LOGGER(...)
#endif

That's the only way that line can make sense.

CodePudding user response:

What does this define macro do?

Defines a macro function that takes any number of arguments and expands to nothing.

Am I wrong about this?

Because the macro expands to nothing, SCOPE_LOGGER("someClass::someFunction()") is removed from the code. Fun fact: the trailing ; stays.

  • Related