How to check if function macro is defined?

I have a line in my code that looks like this:

#ifndef MACRO(n) 

This really works great on most compilers. However, this does not work on Solaris, since the official syntax is # ifndef identifier new-line groupopt , and parentheses are not allowed in identifiers.

What is the correct way to check if this macro is specified?

+5
source share
1 answer

You don't need (n) , actually gcc will complain if you use it:

 warning: extra tokens at end of #ifndef directive 

this is because #ifndef expects the identifier is not an expression, (n) is probably ignored by the preprocessor

Just check with the name of the macro definition:

 #ifndef MACRO 
+7
source

All Articles