:orphan:
# PetscObjectGetName
Gets a string name associated with a PETSc object.
## Synopsis
```
#include "petscsys.h"
PetscErrorCode PetscObjectGetName(PetscObject obj, const char *name[])
```
Not Collective unless object has not been named yet
## Input Parameters
- ***obj -*** the Petsc variable
Thus must be cast with a (`PetscObject`), for example,
`PetscObjectGetName`((`PetscObject`)mat,&name);
- ***name -*** the name associated with obj
## Note
Calls `PetscObjectName()` if a name has not yet been provided to the object.
## See Also
`PetscObjectSetName()`, `PetscObjectName()`, `PetscObject`, `PetscObjectGetId()`
## Level
intermediate
## Location
src/sys/objects/pgname.c
## Examples
src/dm/impls/plex/tutorials/ex11.c
src/dm/impls/plex/tutorials/ex8.c
src/dm/label/tutorials/ex1.c
src/dm/tutorials/ex10.c
src/snes/tutorials/ex36.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/pgname.c)
[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)