# PETSC_NULLPTR
Standard way of indicating a null value or pointer 
## Notes
Equivalent to NULL in C source, and nullptr in C++ source. Note that for the purposes of
interoperability between C and C++, setting a pointer to `PETSC_NULLPTR` in C++ is functonially
equivalent to setting the same pointer to NULL in C. That is to say that the following
expressions are equivalent:

```none
  ptr == PETSC_NULLPTR
  ptr == NULL
  ptr == 0
  !ptr

  ptr = PETSC_NULLPTR
  ptr = NULL
  ptr = 0
```


and for completeness' sake:

```none
  PETSC_NULLPTR == NULL
```



## Fortran Notes
Not available in Fortran


## Example Usage
```none
  // may be used in place of '\0' or other such teminators in the definition of char arrays
  const char *const MyEnumTypes[] = {
    "foo",
    "bar",
    PETSC_NULLPTR
  };

  // may be used to nullify objects
  PetscObject obj = PETSC_NULLPTR;

  // may be used in any function expecting NULL
  PetscInfo(PETSC_NULLPTR,"Lorem Ipsum Dolor");
```



## Developer Notes
`PETSC_NULLPTR` must be used in place of NULL in all C++ source files. Using NULL in source
files compiled with a C++ compiler may lead to unexpected side-effects in function overload
resolution and/or compiler warnings.




## See Also
 `PETSC_CONSTEXPR_14`, `PETSC_NODISCARD`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscmacros.h.html#PETSC_NULLPTR">include/petscmacros.h</A>


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


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