#include <petscmacros.h> boolean PetscHasAttribute(name)
name | - The name of the attribute to test |
As PetscHasAttribute() is wrapper over the function-like macro __has_attribute(), the exact type and value returned is implementation defined. In practice however, it usually returns the integer literal 1 if the attribute is supported, and integer literal 0 if the attribute is not supported.
#if PetscHasAttribute(always_inline) # define MY_ALWAYS_INLINE __attribute__((always_inline)) #else # define MY_ALWAYS_INLINE #endif void foo(void) MY_ALWAYS_INLINE;
but it can also be used in regular code
if (PetscHasAttribute(some_attribute)) { foo(); } else { bar(); }