# PetscHasAttribute
Determine whether a particular __attribute__ is supported by the compiler 
## Synopsis
```
#include <petscmacros.h>
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`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscmacros.h.html#PetscHasAttribute">include/petscmacros.h</A>


---
[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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
