PetscFunctionReturn#
Last executable line of each PETSc function used for error handling. Replaces return().
Synopsis#
#include <petscsys.h>
void PetscFunctionReturn(...)
Not Collective; No Fortran Support
Notes#
This routine is a macro, so while it does not “return” anything itself, it does return from the function in the literal sense.
Usually the return value is PETSC_SUCCESS (for example in any function returning
PetscErrorCode), however it is possible to return any arbitrary type. The arguments of
this macro are placed before the return statement as-is.
Any routine which returns via PetscFunctionReturn() must begin with a corresponding
PetscFunctionBegin.
For routines which return void use PetscFunctionReturnVoid() instead.
Example Usage#
PetscErrorCode foo(int *x)
{
PetscFunctionBegin; // don't forget the begin!
*x = 10;
PetscFunctionReturn(PETSC_SUCCESS);
}
May return any arbitrary type:
struct Foo
{
int x;
};
struct Foo make_foo(int value)
{
struct Foo f;
PetscFunctionBegin;
f.x = value;
PetscFunctionReturn(f);
}
See Also#
PetscFunctionBegin, PetscFunctionBeginUser, PetscFunctionReturnVoid(),
PetscStackPopNoCheck()
Level#
beginner
Location#
Examples#
src/sys/classes/random/tutorials/ex2.c
src/sys/tutorials/ex6.c
src/sys/tutorials/ex7.c
src/sys/classes/draw/tests/ex4.c
src/sys/classes/draw/tests/ex6.c
src/sys/classes/random/tests/ex3.c
src/sys/classes/viewer/tests/ex6.c
src/sys/classes/viewer/tests/ex8.c
src/sys/objects/device/tests/ex11.cxx
src/sys/objects/device/tests/ex3.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages