How to initialise a void** value as NULL?

I have a ctypes _FuncPtr that I’m calling from a Numba cfunc. One of the parameters to this ctypes function has type void**. I need to pass a NULL value, but I’m having trouble with the type system. Neither 0 nor None work as NULL for this pointer to a pointer - I get “Literalint to void**”.

# Succeeds
@numba.cfunc("void()", locals = {"bar": numba.types.voidptr})
def foo():
  bar = 0

# Fails
@numba.cfunc("void()", locals = {"bar": numba.types.CPointer(numba.types.voidptr)})
def foo():
  bar = 0

This feels like a bug so I’ll probably post this to Github too. However I’d really like a quick solution to this - does anyone have a way to make this work?

It seems to work fine if I pass the value in as a parameter, but I can’t do that in this case.

Bug report is here: https://github.com/numba/numba/issues/6535

Hi @SamPruden,

I’ve answered this on the ticket:

workaround is to use @intrinsic .

Hope this helps.

1 Like