PETSc version 3.17.4
Fix/Edit manual page

PetscHasAttribute

Determine whether a particular __attribute__ is supported by the compiler

Synopsis

#include <petscmacros.h>
boolean 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 the integer literal 1 if the attribute is supported, and integer literal 0 if the attribute is not supported.

Example Usage

Typical usage is using the preprocessor

  #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();
  }

See Also

PetscDefined(), PetscLikely(), PetscUnlikely()

Level

intermediate

Location

include/petscmacros.h
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages