How to examine a pointer address?

I am wrapping a library that returns an opaque structure. The call that gives me my result looks like:

 z = @ccall mylib.returns_opaque()::Ptr{Cvoid}

If the structure is properly initialized, it will be nonzero (i.e. not NULL). If it is likely that it is initialized, I’ll get something back like this:

Ptr{Nothing} @0x0000561f9dd53790

If it didn’t work, something like this:

Ptr{Nothing} @0x0000000000000000

How can I differentiate between the two? There don’t seem to be any fields for Ptr?

julia> z
Ptr{Nothing} @0x0000000000000000

julia> z == 0
false

julia> fieldnames(typeof(z))
()

Compare with C_NULL, which is the C null pointer.

2 Likes

On re-examination of the calling C and Fortran page, I do sort-of see it mentioned in there. Sadly things have to be rather explicit for me to pick it up the first time around.