PetscHasBuiltin#

Determine whether a particular builtin method is supported by the compiler

Synopsis#

#include <petscmacros.h>
int PetscHasBuiltin(name)

Input Parameter#

  • name - the name of the builtin routine

Notes#

Evaluates to 1 if the builtin is supported and 0 otherwise. Note the term “evaluates” (vs “expands”) is deliberate; even though PetscHasBuiltin() is a macro the underlying detector is itself is a compiler extension with implementation-defined return type and semantics. Some compilers implement it as a macro, others as a compiler function. In practice however, all supporting compilers return an integer boolean as described.

Example Usage#

Typical usage is in preprocessor directives

  #if PetscHasBuiltin(__builtin_trap)
  __builtin_trap();
  #else
  abort();
  #endif

But it may also be used in regular code

  if (PetscHasBuiltin(__builtin_alloca)) {
    foo();
  } else {
    bar();
  }

See Also#

PetscHasAttribute(), PetscAssume()

Level#

intermediate

Location#

include/petscmacros.h


Edit on GitLab

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages