Skip to main content
`Ctrl`+`K`

# PetscCtx

indicates an argument that can be a pointer to any C struct (or Fortran derived type).

## Notes

This should not be used for arrays of unknown type.

## Fortran Notes

A Fortran code that calls a function with a `PetscCtx` argument would declare the variable `ctx` with

       type(AppType) :: ctx

where `AppType` is a Fortran derived type. Or the argument can be a `PetscObject`.

## Developer Note

`PetscCtx` is used instead of `void *` in PETSc code to enhance the clarity of the PETSc source code since `void *` serves so many different roles. The getAPI() code processor also uses the variable type to generate correct bindings for other languages.

## See Also

Setting Routines and Contexts, `PetscCtxRt`, PetscCtxDestroyFn()`,` PeOp`,` PeNS`,` PetscInitialize()`,` DMGetApplicationContext()`,` DMSetApplicationContextDestroy()`

## Level

developer

## Location

include/petscsys.h

## Examples

src/ksp/ksp/tutorials/ex32.c
src/ksp/ksp/tutorials/ex35.cxx
src/ksp/ksp/tutorials/bench_kspsolve.c
src/dm/field/tutorials/ex1.c
src/dm/tutorials/swarm_ex1.c
src/ksp/ksp/tutorials/ex34.c
src/ksp/ksp/tutorials/ex21.c
src/ksp/ksp/tutorials/ex28.c
src/ksp/ksp/tutorials/ex25.c
src/ksp/ksp/tutorials/ex29.c

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