Passing NULL as an argument through ccall?


#1

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.


#2

Ptr{UInt8}(0)


#3

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


#4

C_NULL doesn’t work.


#5

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

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

Ref{UInt32}

and

Ptr{UInt32}(0)

works perfectly as expected, but if I use…

Ptr{UInt}(0)
Ptr{UInt8}(0)

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