PeCtx — PETSc 3.24.5 documentation

Skip to main content
`Ctrl`+`K`

# PeCtx

indicates an argument that returns a pointer to a user defined C struct (or Fortran derived type)

## Notes

This is not part of the PETSc public API and should only be used in PETSc source code.

This should not be used for functions that return PETSc objects, or pointers to arrays of unknown type. Thus it is used for, for example, `KSPGetApplicationContext()` but not used for `DMNetworkGetComponent()`

For pointers to arrays of unknown type and for functions that return PETSc internal objects that are opaque to users, such as `KSPMonitorDynamicToleranceCreate()` a `void **` should be used.

## Fortran Note

Should only be used with user defined Fortran datatypes

       type(tUserType), pointer :: ctx

## Developer Note

Put this in function declaration for the argument type instead of `void *`, or `void **`.

C compilers generate a warning or error if one passes a pointer to a pointer to a specific type (instead of `void`), for example,

       extern calledfunction(void **);
       SomeCtx *ctx;
       calledfunction(&ctx);   << warning that it is passing a pointer to a pointer to a SomeCtx instead of a void **

By using the common practice of prototyping the function as

       extern calledfunction(void *);

the warning message is averted. `PeCtx` is used in PETSc source code so that the getAPI() code processor knows the argument is actually handled internally as `void **` so it can generate correct bindings for other languages.

## See Also

`PeOp`, `PeNS`, `PetscInitialize()`

## Level

developer

## Location

include/petscsys.h

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