Nullptr in CxxWrap

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?

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:

x.cpp_object == C_NULL

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

1 Like

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