Passing NULL as an argument through ccall?

I cannot seem to figure out how to pass NULL as an argument to a function through the C interface.

I’m using Ref{UInt8} as the argument type.

I’m thinking that I could probably declare it as an Int and just pass 0, but of course the argument could in fact be a valid pointer to data i’ve created in julia.


C_NULL or Ptr{UInt8}(C_NULL) would probably be clearer.

C_NULL doesn’t work.

No, C_NULL alone does not work, but Ptr{UInt8}(C_NULL) does.

Here is an interesting thing. I define my argument as:




works perfectly as expected, but if I use…


I get a non-zero value for the pointer (!) and no complaints from julia in either case that I’ve mixed types