Reputation:
I have a line in my code that looks like this:
#ifndef MACRO(n)
This actually works fine on most compilers. However, this fails on Solaris, because the official syntax is # ifndef identifier new-line groupopt
and parentheses are not allowed in identifiers.
What is the proper way to check whether this macro is defined?
Upvotes: 6
Views: 1901
Reputation: 49986
You dont need (n)
, actually gcc will complain if you use it:
warning: extra tokens at end of #ifndef directive
this is because #ifndef
expects an identifier not expression, (n)
is probably ignored by preprocessor
It should suffice to simply check with macro definition name:
#ifndef MACRO
Upvotes: 8