:orphan:
# PetscUseMethod
Queries a `PetscObject` for a method added with `PetscObjectComposeFunction()`, if it exists then calls it, otherwise generates an error. 
## Synopsis
```
#include "petsc/private/petscimpl.h"
PetscUseMethod(PetscObject obj, const char *name, (arg_types), (arg_value))
```

## Input Parameters

- ***obj -*** the object, for example a `Mat`, that does not need to be cast to `PetscObject`
- ***name -*** the name of the method, for example, "KSPGMRESSetRestart_C" for the function `KSPGMRESSetRestart()`
- ***arg_types -*** the argument types for the method, for example, (KSP,PetscInt)
- ***args -*** the arguments for the method, for example, (ksp,restart))





## Notes
This does not return an error code, it is a macro that returns with an error code on error.

Use `PetscUseTypeMethod()` or `PetscTryTypeMethod()` to call functions that are included in the objects function table, the `ops` array
in the object.


## See Also
 `PetscTryMethod()`, `PetscCall()`, `PetscUseTypeMethod()`, `PetscTryTypeMethod()`, `PetscCheck()`, `PetscObject`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petsc/private/petscimpl.h.html#PetscUseMethod">include/petsc/private/petscimpl.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petsc/private/petscimpl.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
