6

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?

1
  • To clarify. You already know how to check if it is defined, via ifdef MACRO. You want to know specifically if it is a function macro? Commented May 17, 2016 at 11:57

1 Answer 1

8

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.