# Nullptr in CxxWrap

**URL:** <https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150>\
**Category:** General Usage\
**Tags:** cxx\
**Created:** [May 25, 2018, 5:33pm UTC](https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150 "2018-05-25T17:33:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)\
**Post date:** [May 25, 2018, 5:33pm UTC](https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150/1 "2018-05-25T17:33:32Z")

</div>

I’m wrapping an API for a file format (LCIO.jl). This is a serial format and each readNext () call either returns a pointer to the next record or NULL. When wrapping that function, I can’t seem to propagate the comparison against 0 to the Julia side. In other words, comparison against C\_NULL is always false for the pointer returned from CxxWrap, even if the pointer is 0 on the C side. What am I doing wrong? Could somebody point me to an example how to check if the pointer returned from CxxWrap == 0?

---

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [May 25, 2018, 6:47pm UTC](https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150/2 "2018-05-25T18:47:49Z")

</div>

Each value `x` returned from CxxWrap stores the actual C++ object in a pointer field called `cpp_object`, so a null check would look like this:

```julia
x.cpp_object == C_NULL

```

Maybe I should add an `isnull` function for this to CxxWrap, to guard against implementation changes.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 25, 2018, 7:08pm UTC](https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150/3 "2018-05-25T19:08:12Z")

</div>

`getproperty` overloading with a deprecation could also be used if you want to change the name of the field.
