:orphan: # PetscHasAttribute Determine whether a particular __attribute__ is supported by the compiler ## Synopsis ``` #include int PetscHasAttribute(name) ``` ## Input Parameter - ***name -*** The name of the attribute to test ## Notes name should be identical to what you might pass to the __attribute__ declaration itself -- plain, unbroken text. 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 `1` if the attribute is supported and `0` if the attribute is not supported. ## Example Usage Typical usage is using the preprocessor ```none #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 ```none if (PetscHasAttribute(some_attribute)) { foo(); } else { bar(); } ``` ## See Also `PetscHasBuiltin()`, `PetscDefined()`, `PetscLikely()`, `PetscUnlikely()`, `PETSC_ATTRIBUTE_FORMAT`, `PETSC_ATTRIBUTE_MAY_ALIAS` ## Level intermediate ## Location include/petscmacros.h --- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscmacros.h) [Index of all Sys routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)